<!DOCTYPE html><html><head><title>Coverage</title><meta charset="utf-8"><script>

headings = [];

onload = function(){
  headings = document.querySelectorAll('h2');
};

onscroll = function(e){
  var heading = find(window.scrollY);
  if (!heading) return;
  var links = document.querySelectorAll('#menu a')
    , link;

  for (var i = 0, len = links.length; i < len; ++i) {
    link = links[i];
    link.className = link.getAttribute('href') == '#' + heading.id
      ? 'active'
      : '';
  }
};

function find(y) {
  var i = headings.length
    , heading;

  while (i--) {
    heading = headings[i];
    if (y >= heading.offsetTop) {
      return heading;
    }
  }
}
</script>
<style>

body {
  font: 14px/1.6 "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: 0;
  color: #2C2C2C;
  border-top: 2px solid #ddd;
}

#coverage {
  padding: 60px 400px 60px 60px;
}

h1 a {
  color: inherit;
  font-weight: inherit;
}

h1 a:hover {
  text-decoration: none;
}

.onload h1 {
  opacity: 1;
}

h2 {
  width: 80%;
  margin-top: 80px;
  margin-bottom: 0;
  font-weight: 100;
  letter-spacing: 1px;
  border-bottom: 1px solid #eee;
}

a {
  color: #8A6343;
  font-weight: bold;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul {
  margin-top: 20px;
  padding: 0 15px;
  width: 100%;
}

ul li {
  float: left;
  width: 40%;
  margin-top: 5px;
  margin-right: 60px;
  list-style: none;
  border-bottom: 1px solid #eee;
  padding: 5px 0;
  font-size: 12px;
}

ul::after {
  content: '.';
  height: 0;
  display: block;
  visibility: hidden;
  clear: both;
}

code {
  font: 12px monaco, monospace;
}

pre {
  margin: 30px;
  padding: 30px;
  border: 1px solid #eee;
  border-bottom-color: #ddd;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  border-radius: 2px;
  -webkit-box-shadow: inset 0 0 10px #eee;
  -moz-box-shadow: inset 0 0 10px #eee;
  box-shadow: inset 0 0 10px #eee;
  overflow-x: auto;
}

img {
  margin: 30px;
  padding: 1px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  -webkit-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
  -moz-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
  box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
  max-width: 100%;
}

footer {
  background: #eee;
  width: 100%;
  padding: 50px 0;
  text-align: right;
  border-top: 1px solid #ddd;
}

footer span {
  display: block;
  margin-right: 30px;
  color: #888;
  font-size: 12px;
}

#menu {
  position: fixed;
  font-size: 12px;
  overflow-y: auto;
  top: 0;
  right: 0;
  margin: 0;
  height: 100%;
  padding: 15px 0;
  text-align: right;
  border-left: 1px solid #eee;
  max-width: 400px;
  overflow: auto;
  white-space: nowrap;
  
  -moz-box-shadow: 0 0 2px #888
     , inset 5px 0 20px rgba(0,0,0,.5)
     , inset 5px 0 3px rgba(0,0,0,.3);
  -webkit-box-shadow: 0 0 2px #888
     , inset 5px 0 20px rgba(0,0,0,.5)
     , inset 5px 0 3px rgba(0,0,0,.3);
  box-shadow: 0 0 2px #888
     , inset 5px 0 20px rgba(0,0,0,.5)
     , inset 5px 0 3px rgba(0,0,0,.3);
  -webkit-font-smoothing: antialiased;
  background: url("");
}

#menu::after {
  display: block;
  content: '';
  padding-top: 80px;
}

#logo {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background: rgba(255,255,255,.1);
  font-size: 11px;
  display: block;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  -webkit-border-radius: 20px;
  -moz-border-radius: 20px;
  border-radius: 20px;
  -webkit-box-shadow: 0 0 3px rgba(0,0,0,.2);
  -moz-box-shadow: 0 0 3px rgba(0,0,0,.2);
  box-shadow: 0 0 3px rgba(0,0,0,.2);
  color: inherit;
}

#menu li a {
  display: block;
  color: white;
  padding: 0 35px 0 25px;
  -webkit-transition: background 300ms;
  -moz-transition: background 300ms;
}

#menu li {
  position: relative;
  list-style: none;
}

#menu a:hover,
#menu a.active {
  text-decoration: none;
  background: rgba(255,255,255,.1);
}

#menu li:hover .cov {
  opacity: 1;
}

#menu li .dirname {
  opacity: .60;
  padding-right: 2px;
}

#menu li .basename {
  opacity: 1;
}

#menu .cov {
  background: rgba(0,0,0,.4);
  position: absolute;
  top: 0;
  right: 8px;
  font-size: 9px;
  opacity: .6;
  text-align: left;
  width: 17px;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
  padding: 2px 3px;
  text-align: center;
}

#stats:nth-child(2n) {
  display: inline-block;
  margin-top: 15px;
  border: 1px solid #eee;
  padding: 10px;
  -webkit-box-shadow: inset 0 0 2px #eee;
  -moz-box-shadow: inset 0 0 2px #eee;
  box-shadow: inset 0 0 2px #eee;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
}

#stats div {
  float: left;
  padding: 0 5px;
}

#stats::after {
  display: block;
  content: '';
  clear: both;
}

#stats .sloc::after {
  content: ' SLOC';
  color: #b6b6b6;
}

#stats .percentage::after {
  content: ' coverage';
  color: #b6b6b6;
}

#stats .hits,
#stats .misses {
  display: none;
}

.high {
  color: #00d4b4;
}
.medium {
  color: #e87d0d;
}
.low {
  color: #d4081a;
}
.terrible {
  color: #d4081a;
  font-weight: bold;
}

table {
  width: 80%;
  margin-top: 10px;
  border-collapse: collapse;
  border: 1px solid #cbcbcb;
  color: #363636;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}

table thead {
  display: none;
}

table td.line,
table td.hits {
  width: 20px;
  background: #eaeaea;
  text-align: center;
  font-size: 11px;
  padding: 0 10px;
  color: #949494;
}

table td.hits {
  width: 10px;
  padding: 2px 5px;
  color: rgba(0,0,0,.2);
  background: #f0f0f0;
}

tr.miss td.line,
tr.miss td.hits {
  background: #e6c3c7;
}

tr.miss td {
  background: #f8d5d8;
}

td.source {
  padding-left: 15px;
  line-height: 15px;
  white-space: pre;
  font: 12px monaco, monospace;
}

code .comment { color: #ddd }
code .init { color: #2F6FAD }
code .string { color: #5890AD }
code .keyword { color: #8A6343 }
code .number { color: #2F6FAD }
</style>
</head><body><div id="coverage"><h1 id="overview">Coverage</h1><div id="menu"><li><a href="#overview">overview</a></li><li><span class="cov high">86</span><a href="#/home/johan/DevZone/JsBarcode/JsBarcode.js"><span class="dirname">/home/johan/DevZone/JsBarcode/</span><span class="basename">JsBarcode.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/CODE128.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">CODE128.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/CODE39.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">CODE39.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/EAN_UPC.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">EAN_UPC.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/ITF.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">ITF.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/ITF14.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">ITF14.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/MSI.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">MSI.js</span></a></li><li><span class="cov high">100</span><a href="#/home/johan/DevZone/JsBarcode/barcodes/pharmacode.js"><span class="dirname">/home/johan/DevZone/JsBarcode/barcodes/</span><span class="basename">pharmacode.js</span></a></li><a id="logo" href="http://mochajs.org/">m</a></div><div id="stats" class="high"><div class="percentage">97%</div><div class="sloc">571</div><div class="hits">554</div><div class="misses">17</div></div><div id="files"><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/JsBarcode.js">/home/johan/DevZone/JsBarcode/JsBarcode.js</h2><div id="stats" class="high"><div class="percentage">86%</div><div class="sloc">130</div><div class="hits">113</div><div class="misses">17</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">(function(){</td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">3</td><td class="hits"></td><td class="source">	// Main function, calls drawCanvas(...) in the right way</td></tr><tr class="hit"><td class="line">4</td><td class="hits">1</td><td class="source">	var JsBarcode = function(image, content, options){</td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source">		// If the image is a string, query select call again</td></tr><tr class="hit"><td class="line">6</td><td class="hits">21</td><td class="source">		if(typeof image === &quot;string&quot;){</td></tr><tr class="hit"><td class="line">7</td><td class="hits">1</td><td class="source">			image = document.querySelector(image);</td></tr><tr class="miss"><td class="line">8</td><td class="hits">0</td><td class="source">			JsBarcode(image, content, options);</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source">		// If image, draw on canvas and set the uri as src</td></tr><tr class="hit"><td class="line">11</td><td class="hits">20</td><td class="source">		else if(typeof HTMLCanvasElement !== 'undefined' &amp;&amp; image instanceof HTMLImageElement){</td></tr><tr class="miss"><td class="line">12</td><td class="hits">0</td><td class="source">			canvas = document.createElement('canvas');</td></tr><tr class="miss"><td class="line">13</td><td class="hits">0</td><td class="source">			drawCanvas(canvas, content, options);</td></tr><tr class="miss"><td class="line">14</td><td class="hits">0</td><td class="source">			image.setAttribute(&quot;src&quot;, canvas.toDataURL());</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source">		// If canvas, just draw</td></tr><tr class="hit"><td class="line">17</td><td class="hits">20</td><td class="source">		else if(image.getContext){</td></tr><tr class="hit"><td class="line">18</td><td class="hits">19</td><td class="source">			drawCanvas(image, content, options);</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">21</td><td class="hits">1</td><td class="source">			throw new Error(&quot;Not supported type to draw on.&quot;);</td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">	// The main function, handles everything with the modules and draws the image</td></tr><tr class="hit"><td class="line">26</td><td class="hits">1</td><td class="source">	var drawCanvas = function(canvas, content, options) {</td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source">		// Merge the user options with the default</td></tr><tr class="hit"><td class="line">28</td><td class="hits">19</td><td class="source">		options = merge(JsBarcode.defaults, options);</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source">		// Fix the margins</td></tr><tr class="hit"><td class="line">31</td><td class="hits">19</td><td class="source">		options.marginTop = options.marginTop | options.margin;</td></tr><tr class="hit"><td class="line">32</td><td class="hits">19</td><td class="source">		options.marginBottom = options.marginBottom | options.margin;</td></tr><tr class="hit"><td class="line">33</td><td class="hits">19</td><td class="source">		options.marginRight = options.marginRight | options.margin;</td></tr><tr class="hit"><td class="line">34</td><td class="hits">19</td><td class="source">		options.marginLeft = options.marginLeft | options.margin;</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">		//Abort if the browser does not support HTML5 canvas</td></tr><tr class="hit"><td class="line">37</td><td class="hits">19</td><td class="source">		if (!canvas.getContext) {</td></tr><tr class="miss"><td class="line">38</td><td class="hits">0</td><td class="source">			throw new Error('The browser does not support canvas.');</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">		// Automatically choose barcode if format set to &quot;auto&quot;...</td></tr><tr class="hit"><td class="line">42</td><td class="hits">19</td><td class="source">		if(options.format == &quot;auto&quot;){</td></tr><tr class="hit"><td class="line">43</td><td class="hits">3</td><td class="source">			var encoder = new (JsBarcode.autoSelectEncoder(content))(content);</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">45</td><td class="hits"></td><td class="source">		// ...or else, get by name</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">47</td><td class="hits">16</td><td class="source">			var encoder = new (JsBarcode.getModule(options.format))(content);</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">		//Abort if the barcode format does not support the content</td></tr><tr class="hit"><td class="line">51</td><td class="hits">18</td><td class="source">		if(!encoder.valid()){</td></tr><tr class="hit"><td class="line">52</td><td class="hits">2</td><td class="source">		  options.valid(false);</td></tr><tr class="hit"><td class="line">53</td><td class="hits">2</td><td class="source">			if(options.valid == JsBarcode.defaults.valid){</td></tr><tr class="hit"><td class="line">54</td><td class="hits">1</td><td class="source">				throw new Error('The data is not valid for the type of barcode.');</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">56</td><td class="hits">1</td><td class="source">			return;</td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">		// Set the binary to a cached version if possible</td></tr><tr class="hit"><td class="line">60</td><td class="hits">16</td><td class="source">		var cachedBinary = JsBarcode.getCache(options.format, content);</td></tr><tr class="hit"><td class="line">61</td><td class="hits">16</td><td class="source">		if(cachedBinary){</td></tr><tr class="hit"><td class="line">62</td><td class="hits">9</td><td class="source">			var binary = cachedBinary;</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">		else{</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">			// Encode the content</td></tr><tr class="hit"><td class="line">66</td><td class="hits">7</td><td class="source">			var binary = encoder.encoded();</td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">			// Cache the encoding if it will be used again later</td></tr><tr class="hit"><td class="line">68</td><td class="hits">7</td><td class="source">			JsBarcode.cache(options.format, content, binary);</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source">		// Get the canvas context</td></tr><tr class="hit"><td class="line">72</td><td class="hits">16</td><td class="source">		var ctx = canvas.getContext(&quot;2d&quot;);</td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source">		// Set font</td></tr><tr class="hit"><td class="line">75</td><td class="hits">16</td><td class="source">		var font = options.fontOptions + &quot; &quot; + options.fontSize + &quot;px &quot;+options.font;</td></tr><tr class="hit"><td class="line">76</td><td class="hits">16</td><td class="source">		ctx.font = font;</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source">		// Set the width and height of the barcode</td></tr><tr class="hit"><td class="line">79</td><td class="hits">16</td><td class="source">		var width = binary.length*options.width;</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source">		// Replace with width of the text if it is wider then the barcode</td></tr><tr class="hit"><td class="line">81</td><td class="hits">16</td><td class="source">		var textWidth = ctx.measureText(encoder.getText()).width;</td></tr><tr class="hit"><td class="line">82</td><td class="hits">16</td><td class="source">		if(options.displayValue &amp;&amp; width &lt; textWidth){</td></tr><tr class="miss"><td class="line">83</td><td class="hits">0</td><td class="source">			if(options.textAlign == &quot;center&quot;){</td></tr><tr class="miss"><td class="line">84</td><td class="hits">0</td><td class="source">				var barcodePadding = Math.floor((textWidth - width)/2);</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source">			}</td></tr><tr class="miss"><td class="line">86</td><td class="hits">0</td><td class="source">			else if(options.textAlign == &quot;left&quot;){</td></tr><tr class="miss"><td class="line">87</td><td class="hits">0</td><td class="source">				var barcodePadding = 0;</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source">			}</td></tr><tr class="miss"><td class="line">89</td><td class="hits">0</td><td class="source">			else if(options.textAlign == &quot;right&quot;){</td></tr><tr class="miss"><td class="line">90</td><td class="hits">0</td><td class="source">				var barcodePadding = Math.floor(textWidth - width);</td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source"> </td></tr><tr class="miss"><td class="line">93</td><td class="hits">0</td><td class="source">			width = textWidth;</td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source">		// Make sure barcodePadding is not undefined</td></tr><tr class="hit"><td class="line">96</td><td class="hits">16</td><td class="source">		var barcodePadding = barcodePadding || 0;</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">98</td><td class="hits">16</td><td class="source">		canvas.width = width + options.marginLeft + options.marginRight;</td></tr><tr><td class="line">99</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">100</td><td class="hits"></td><td class="source">		// Set extra height if the value is displayed under the barcode. Multiplication with 1.3 t0 ensure that some</td></tr><tr><td class="line">101</td><td class="hits"></td><td class="source">		//characters are not cut in half</td></tr><tr class="hit"><td class="line">102</td><td class="hits">16</td><td class="source">		canvas.height = options.height</td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source">			+ (options.displayValue ? options.fontSize : 0)</td></tr><tr><td class="line">104</td><td class="hits"></td><td class="source">			+ options.textMargin</td></tr><tr><td class="line">105</td><td class="hits"></td><td class="source">			+ options.marginTop</td></tr><tr><td class="line">106</td><td class="hits"></td><td class="source">			+ options.marginBottom;</td></tr><tr><td class="line">107</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source">		// Paint the canvas</td></tr><tr class="hit"><td class="line">109</td><td class="hits">16</td><td class="source">		ctx.clearRect(0,0,canvas.width,canvas.height);</td></tr><tr class="hit"><td class="line">110</td><td class="hits">16</td><td class="source">		if(options.background){</td></tr><tr class="hit"><td class="line">111</td><td class="hits">16</td><td class="source">			ctx.fillStyle = options.background;</td></tr><tr class="hit"><td class="line">112</td><td class="hits">16</td><td class="source">			ctx.fillRect(0,0,canvas.width, canvas.height);</td></tr><tr><td class="line">113</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">114</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">115</td><td class="hits"></td><td class="source">		// Creates the barcode out of the encoded binary</td></tr><tr class="hit"><td class="line">116</td><td class="hits">16</td><td class="source">		ctx.fillStyle = options.lineColor;</td></tr><tr class="hit"><td class="line">117</td><td class="hits">16</td><td class="source">		for(var i=0;i&lt;binary.length;i++){</td></tr><tr class="hit"><td class="line">118</td><td class="hits">1538</td><td class="source">			var x = i*options.width + options.marginLeft + barcodePadding;</td></tr><tr class="hit"><td class="line">119</td><td class="hits">1538</td><td class="source">			if(binary[i] == &quot;1&quot;){</td></tr><tr class="hit"><td class="line">120</td><td class="hits">730</td><td class="source">				ctx.fillRect(x, options.marginTop, options.width, options.height);</td></tr><tr><td class="line">121</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">122</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">123</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">124</td><td class="hits"></td><td class="source">		// Draw the text if displayValue is set</td></tr><tr class="hit"><td class="line">125</td><td class="hits">16</td><td class="source">		if(options.displayValue){</td></tr><tr class="hit"><td class="line">126</td><td class="hits">15</td><td class="source">			var x, y;</td></tr><tr><td class="line">127</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">128</td><td class="hits">15</td><td class="source">			y = options.height + options.textMargin + options.marginTop;</td></tr><tr><td class="line">129</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">130</td><td class="hits">15</td><td class="source">			ctx.font = font;</td></tr><tr class="hit"><td class="line">131</td><td class="hits">15</td><td class="source">			ctx.textBaseline = &quot;bottom&quot;;</td></tr><tr class="hit"><td class="line">132</td><td class="hits">15</td><td class="source">			ctx.textBaseline = 'top';</td></tr><tr><td class="line">133</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">134</td><td class="hits"></td><td class="source">			// Draw the text in the correct X depending on the textAlign option</td></tr><tr class="hit"><td class="line">135</td><td class="hits">15</td><td class="source">			if(options.textAlign == &quot;left&quot; || barcodePadding &gt; 0){</td></tr><tr class="hit"><td class="line">136</td><td class="hits">1</td><td class="source">				x = options.marginLeft;</td></tr><tr class="hit"><td class="line">137</td><td class="hits">1</td><td class="source">				ctx.textAlign = 'left';</td></tr><tr><td class="line">138</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">139</td><td class="hits">14</td><td class="source">			else if(options.textAlign == &quot;right&quot;){</td></tr><tr class="hit"><td class="line">140</td><td class="hits">1</td><td class="source">				x = canvas.width - options.marginRight;</td></tr><tr class="hit"><td class="line">141</td><td class="hits">1</td><td class="source">				ctx.textAlign = 'right';</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">143</td><td class="hits"></td><td class="source">			//In all other cases, center the text</td></tr><tr><td class="line">144</td><td class="hits"></td><td class="source">			else{</td></tr><tr class="hit"><td class="line">145</td><td class="hits">13</td><td class="source">				x = canvas.width / 2;</td></tr><tr class="hit"><td class="line">146</td><td class="hits">13</td><td class="source">				ctx.textAlign = 'center';</td></tr><tr><td class="line">147</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">148</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">149</td><td class="hits">15</td><td class="source">			ctx.fillText(encoder.getText(), x, y);</td></tr><tr><td class="line">150</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">151</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">152</td><td class="hits"></td><td class="source">		// Send a confirmation that the generation was successful to the valid function if it does exist</td></tr><tr class="hit"><td class="line">153</td><td class="hits">16</td><td class="source">		options.valid(true);</td></tr><tr><td class="line">154</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">155</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">156</td><td class="hits">1</td><td class="source">	JsBarcode._modules = [];</td></tr><tr><td class="line">157</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">158</td><td class="hits"></td><td class="source">	// Add a new module sorted in the array</td></tr><tr class="hit"><td class="line">159</td><td class="hits">1</td><td class="source">	JsBarcode.register = function(module, regex, priority){</td></tr><tr class="hit"><td class="line">160</td><td class="hits">17</td><td class="source">		var position = 0;</td></tr><tr class="hit"><td class="line">161</td><td class="hits">17</td><td class="source">		if(typeof priority === &quot;undefined&quot;){</td></tr><tr class="hit"><td class="line">162</td><td class="hits">4</td><td class="source">			position = JsBarcode._modules.length - 1;</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">164</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">165</td><td class="hits">13</td><td class="source">			for(var i=0;i&lt;JsBarcode._modules.length;i++){</td></tr><tr class="hit"><td class="line">166</td><td class="hits">38</td><td class="source">				position = i;</td></tr><tr class="hit"><td class="line">167</td><td class="hits">38</td><td class="source">				if(!(priority &lt; JsBarcode._modules[i].priority)){</td></tr><tr class="hit"><td class="line">168</td><td class="hits">10</td><td class="source">					break;</td></tr><tr><td class="line">169</td><td class="hits"></td><td class="source">				}</td></tr><tr><td class="line">170</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">171</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">173</td><td class="hits"></td><td class="source">		// Add the module in position position</td></tr><tr class="hit"><td class="line">174</td><td class="hits">17</td><td class="source">		JsBarcode._modules.splice(position, 0, {</td></tr><tr><td class="line">175</td><td class="hits"></td><td class="source">			&quot;regex&quot;: regex,</td></tr><tr><td class="line">176</td><td class="hits"></td><td class="source">			&quot;module&quot;: module,</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source">			&quot;priority&quot;: priority</td></tr><tr><td class="line">178</td><td class="hits"></td><td class="source">		});</td></tr><tr><td class="line">179</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">180</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">181</td><td class="hits"></td><td class="source">	// Get module by name</td></tr><tr class="hit"><td class="line">182</td><td class="hits">1</td><td class="source">	JsBarcode.getModule = function(name){</td></tr><tr class="hit"><td class="line">183</td><td class="hits">33</td><td class="source">		for(var i in JsBarcode._modules){</td></tr><tr class="hit"><td class="line">184</td><td class="hits">368</td><td class="source">			if(name.search(JsBarcode._modules[i].regex) !== -1){</td></tr><tr class="hit"><td class="line">185</td><td class="hits">32</td><td class="source">				return JsBarcode._modules[i].module;</td></tr><tr><td class="line">186</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">187</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">188</td><td class="hits">1</td><td class="source">		throw new Error('Module ' + name + ' does not exist or is not loaded.');</td></tr><tr><td class="line">189</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">190</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">191</td><td class="hits"></td><td class="source">	// If any format is valid with the content, return the format with highest priority</td></tr><tr class="hit"><td class="line">192</td><td class="hits">1</td><td class="source">	JsBarcode.autoSelectEncoder = function(content){</td></tr><tr class="hit"><td class="line">193</td><td class="hits">3</td><td class="source">		for(var i in JsBarcode._modules){</td></tr><tr class="hit"><td class="line">194</td><td class="hits">17</td><td class="source">			var barcode = new (JsBarcode._modules[i].module)(content);</td></tr><tr class="hit"><td class="line">195</td><td class="hits">17</td><td class="source">			if(barcode.valid(content)){</td></tr><tr class="hit"><td class="line">196</td><td class="hits">3</td><td class="source">				return JsBarcode._modules[i].module;</td></tr><tr><td class="line">197</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">198</td><td class="hits"></td><td class="source">		}</td></tr><tr class="miss"><td class="line">199</td><td class="hits">0</td><td class="source">		throw new Error(&quot;Can't automatically find a barcode format matching the string '&quot; + content + &quot;'&quot;);</td></tr><tr><td class="line">200</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">201</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">202</td><td class="hits"></td><td class="source">	// Defining the cache dictionary</td></tr><tr class="hit"><td class="line">203</td><td class="hits">1</td><td class="source">	JsBarcode._cache = {};</td></tr><tr><td class="line">204</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">205</td><td class="hits"></td><td class="source">	// Cache a regerated barcode</td></tr><tr class="hit"><td class="line">206</td><td class="hits">1</td><td class="source">	JsBarcode.cache = function(format, input, output){</td></tr><tr class="hit"><td class="line">207</td><td class="hits">7</td><td class="source">		if(!JsBarcode._cache[format]){</td></tr><tr class="hit"><td class="line">208</td><td class="hits">4</td><td class="source">			JsBarcode._cache[format] = {};</td></tr><tr><td class="line">209</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">210</td><td class="hits">7</td><td class="source">		JsBarcode._cache[format][input] = output;</td></tr><tr><td class="line">211</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">212</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">213</td><td class="hits"></td><td class="source">	// Get a chached barcode</td></tr><tr class="hit"><td class="line">214</td><td class="hits">1</td><td class="source">	JsBarcode.getCache = function(format, input){</td></tr><tr class="hit"><td class="line">215</td><td class="hits">16</td><td class="source">		if(JsBarcode._cache[format]){</td></tr><tr class="hit"><td class="line">216</td><td class="hits">12</td><td class="source">			if(JsBarcode._cache[format][input]){</td></tr><tr class="hit"><td class="line">217</td><td class="hits">9</td><td class="source">				return JsBarcode._cache[format][input];</td></tr><tr><td class="line">218</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">219</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">220</td><td class="hits">7</td><td class="source">		return &quot;&quot;;</td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">222</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">223</td><td class="hits"></td><td class="source">	// Detect if the code is running under nodejs</td></tr><tr class="hit"><td class="line">224</td><td class="hits">1</td><td class="source">	JsBarcode._isNode = false;</td></tr><tr class="hit"><td class="line">225</td><td class="hits">1</td><td class="source">	if (typeof module !== 'undefined' &amp;&amp; module.exports) {</td></tr><tr class="hit"><td class="line">226</td><td class="hits">1</td><td class="source">		module.exports = JsBarcode;	// Export to nodejs</td></tr><tr class="hit"><td class="line">227</td><td class="hits">1</td><td class="source">		JsBarcode._isNode = true;</td></tr><tr><td class="line">228</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">229</td><td class="hits"></td><td class="source">		//Register all modules in ./barcodes/</td></tr><tr class="hit"><td class="line">230</td><td class="hits">1</td><td class="source">		var path = require(&quot;path&quot;);</td></tr><tr class="hit"><td class="line">231</td><td class="hits">1</td><td class="source">		var dir = path.join(__dirname, &quot;barcodes&quot;);</td></tr><tr class="hit"><td class="line">232</td><td class="hits">1</td><td class="source">		var files = require(&quot;fs&quot;).readdirSync(dir);</td></tr><tr class="hit"><td class="line">233</td><td class="hits">1</td><td class="source">		for(var i in files){</td></tr><tr class="hit"><td class="line">234</td><td class="hits">8</td><td class="source">			var barcode = require(path.join(dir, files[i]));</td></tr><tr class="hit"><td class="line">235</td><td class="hits">8</td><td class="source">			barcode.register(JsBarcode);</td></tr><tr><td class="line">236</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">237</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">238</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">239</td><td class="hits"></td><td class="source">	//Regsiter JsBarcode for the browser</td></tr><tr class="hit"><td class="line">240</td><td class="hits">1</td><td class="source">	if(typeof window !== 'undefined'){</td></tr><tr class="miss"><td class="line">241</td><td class="hits">0</td><td class="source">		window.JsBarcode = JsBarcode;</td></tr><tr><td class="line">242</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">243</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">244</td><td class="hits"></td><td class="source">	// Register JsBarcode as an jQuery plugin if jQuery exist</td></tr><tr class="hit"><td class="line">245</td><td class="hits">1</td><td class="source">	if (typeof jQuery !== 'undefined') {</td></tr><tr class="miss"><td class="line">246</td><td class="hits">0</td><td class="source">		jQuery.fn.JsBarcode = function(content, options, validFunction){</td></tr><tr class="miss"><td class="line">247</td><td class="hits">0</td><td class="source">			JsBarcode(this.get(0), content, options, validFunction);</td></tr><tr class="miss"><td class="line">248</td><td class="hits">0</td><td class="source">			return this;</td></tr><tr><td class="line">249</td><td class="hits"></td><td class="source">		};</td></tr><tr><td class="line">250</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">251</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">252</td><td class="hits"></td><td class="source">	// All the default options. If one is not set.</td></tr><tr class="hit"><td class="line">253</td><td class="hits">1</td><td class="source">	JsBarcode.defaults = {</td></tr><tr><td class="line">254</td><td class="hits"></td><td class="source">		width: 2,</td></tr><tr><td class="line">255</td><td class="hits"></td><td class="source">		height: 100,</td></tr><tr><td class="line">256</td><td class="hits"></td><td class="source">		format: &quot;auto&quot;,</td></tr><tr><td class="line">257</td><td class="hits"></td><td class="source">		displayValue: true,</td></tr><tr><td class="line">258</td><td class="hits"></td><td class="source">		fontOptions: &quot;&quot;,</td></tr><tr><td class="line">259</td><td class="hits"></td><td class="source">		font: &quot;monospace&quot;,</td></tr><tr><td class="line">260</td><td class="hits"></td><td class="source">		textAlign: &quot;center&quot;,</td></tr><tr><td class="line">261</td><td class="hits"></td><td class="source">		textMargin: 2,</td></tr><tr><td class="line">262</td><td class="hits"></td><td class="source">		fontSize: 20,</td></tr><tr><td class="line">263</td><td class="hits"></td><td class="source">		background: &quot;#ffffff&quot;,</td></tr><tr><td class="line">264</td><td class="hits"></td><td class="source">		lineColor: &quot;#000000&quot;,</td></tr><tr><td class="line">265</td><td class="hits"></td><td class="source">		margin: 10,</td></tr><tr><td class="line">266</td><td class="hits"></td><td class="source">		marginTop: undefined,</td></tr><tr><td class="line">267</td><td class="hits"></td><td class="source">		marginBottom: undefined,</td></tr><tr><td class="line">268</td><td class="hits"></td><td class="source">		marginLeft: undefined,</td></tr><tr><td class="line">269</td><td class="hits"></td><td class="source">		marginRight: undefined,</td></tr><tr><td class="line">270</td><td class="hits"></td><td class="source">		valid: function(valid){}</td></tr><tr><td class="line">271</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">272</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">273</td><td class="hits"></td><td class="source">	// Function to merge the default options with the default ones</td></tr><tr class="hit"><td class="line">274</td><td class="hits">1</td><td class="source">	var merge = function(m1, m2) {</td></tr><tr class="hit"><td class="line">275</td><td class="hits">19</td><td class="source">		var newMerge = {};</td></tr><tr class="hit"><td class="line">276</td><td class="hits">19</td><td class="source">		for (var k in m1) {</td></tr><tr class="hit"><td class="line">277</td><td class="hits">323</td><td class="source">			newMerge[k] = m1[k];</td></tr><tr><td class="line">278</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">279</td><td class="hits">19</td><td class="source">		for (var k in m2) {</td></tr><tr class="hit"><td class="line">280</td><td class="hits">26</td><td class="source">			if(typeof m2[k] !== &quot;undefined&quot;){</td></tr><tr class="hit"><td class="line">281</td><td class="hits">26</td><td class="source">				newMerge[k] = m2[k];</td></tr><tr><td class="line">282</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">283</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">284</td><td class="hits">19</td><td class="source">		return newMerge;</td></tr><tr><td class="line">285</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">286</td><td class="hits"></td><td class="source">})();</td></tr><tr><td class="line">287</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/CODE128.js">/home/johan/DevZone/JsBarcode/barcodes/CODE128.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">157</div><div class="hits">157</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr><td class="line">1</td><td class="hits"></td><td class="source">// ASCII value ranges 0-127, 200-211</td></tr><tr class="hit"><td class="line">2</td><td class="hits">1</td><td class="source">var validCODE128 = /^[\x00-\x7F\xC8-\xD3]+$/;</td></tr><tr><td class="line">3</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source">// This is the master class, it does require the start code to be</td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source">//included in the string</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">function CODE128(string) {</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source">	// Fill the bytes variable with the ascii codes of string</td></tr><tr class="hit"><td class="line">8</td><td class="hits">29</td><td class="source">	this.bytes = [];</td></tr><tr class="hit"><td class="line">9</td><td class="hits">29</td><td class="source">	for (var i = 0; i &lt; string.length; ++i) {</td></tr><tr class="hit"><td class="line">10</td><td class="hits">232</td><td class="source">		this.bytes.push(string.charCodeAt(i));</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source">	// First element should be startcode, remove that</td></tr><tr class="hit"><td class="line">14</td><td class="hits">29</td><td class="source">	this.string = string.substring(1);</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">16</td><td class="hits">29</td><td class="source">	this.getText = function() {</td></tr><tr class="hit"><td class="line">17</td><td class="hits">19</td><td class="source">		var string = this.string;</td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">19</td><td class="hits">19</td><td class="source">		string = string.replace(String.fromCharCode(201), &quot;[FNC3]&quot;);</td></tr><tr class="hit"><td class="line">20</td><td class="hits">19</td><td class="source">		string = string.replace(String.fromCharCode(202), &quot;[FNC2]&quot;);</td></tr><tr class="hit"><td class="line">21</td><td class="hits">19</td><td class="source">		string = string.replace(String.fromCharCode(203), &quot;[SHIFT]&quot;);</td></tr><tr class="hit"><td class="line">22</td><td class="hits">19</td><td class="source">		string = string.replace(String.fromCharCode(207), &quot;[FNC1]&quot;);</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">24</td><td class="hits">19</td><td class="source">		return string.replace(/[^\x20-\x7E]/g, &quot;&quot;);</td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source">	// The public encoding function</td></tr><tr class="hit"><td class="line">28</td><td class="hits">29</td><td class="source">	this.encoded = function() {</td></tr><tr class="hit"><td class="line">29</td><td class="hits">11</td><td class="source">		var encodingResult;</td></tr><tr class="hit"><td class="line">30</td><td class="hits">11</td><td class="source">		var bytes = this.bytes;</td></tr><tr><td class="line">31</td><td class="hits"></td><td class="source">		// Remove the startcode from the bytes and set its index</td></tr><tr class="hit"><td class="line">32</td><td class="hits">11</td><td class="source">		var startIndex = bytes.shift() - 105;</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source">		// Start encode with the right type</td></tr><tr class="hit"><td class="line">35</td><td class="hits">11</td><td class="source">		if(startIndex === 103){</td></tr><tr class="hit"><td class="line">36</td><td class="hits">4</td><td class="source">			encodingResult = nextA(bytes, 1);</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">38</td><td class="hits">7</td><td class="source">		else if(startIndex === 104){</td></tr><tr class="hit"><td class="line">39</td><td class="hits">4</td><td class="source">			encodingResult = nextB(bytes, 1);</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">41</td><td class="hits">3</td><td class="source">		else if(startIndex === 105){</td></tr><tr class="hit"><td class="line">42</td><td class="hits">3</td><td class="source">			encodingResult = nextC(bytes, 1);</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">45</td><td class="hits">11</td><td class="source">		return (</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">			//Add the start bits</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source">			getEncoding(startIndex) +</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">			//Add the encoded bits</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">			encodingResult.result +</td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">			//Add the checksum</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">			getEncoding((encodingResult.checksum + startIndex) % 103) +</td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source">			//Add the end bits</td></tr><tr><td class="line">53</td><td class="hits"></td><td class="source">			getEncoding(106)</td></tr><tr><td class="line">54</td><td class="hits"></td><td class="source">		);</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">	//Data for each character, the last characters will not be encoded but are used for error correction</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source">	//Numbers encode to (n + 1000) -&gt; binary; 740 -&gt; (740 + 1000).toString(2) -&gt; &quot;11011001100&quot;</td></tr><tr class="hit"><td class="line">59</td><td class="hits">29</td><td class="source">	var code128b = [ // + 1000</td></tr><tr><td class="line">60</td><td class="hits"></td><td class="source">			740, 644, 638, 176, 164, 100, 224, 220, 124, 608, 604,</td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source">			572, 436, 244, 230, 484, 260, 254, 650, 628, 614, 764,</td></tr><tr><td class="line">62</td><td class="hits"></td><td class="source">			652, 902, 868, 836, 830, 892, 844, 842, 752, 734, 590,</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source">			304, 112,  94, 416, 128, 122, 672, 576, 570, 464, 422,</td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">			134, 496, 478, 142, 910, 678, 582, 768, 762, 774, 880,</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">			862, 814, 896, 890, 818, 914, 602, 930, 328, 292, 200,</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source">			158,  68,  62, 424, 412, 232, 218,  76,  74, 554, 616,</td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">			978, 556, 146, 340, 212, 182, 508, 268, 266, 956, 940,</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">			938, 758, 782, 974, 400, 310, 118, 512, 506, 960, 954,</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">			502, 518, 886, 966, /* Start codes */   668, 680, 692,</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source">			5379</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source">		];</td></tr><tr class="hit"><td class="line">72</td><td class="hits">29</td><td class="source">	var getEncoding = function(n) {</td></tr><tr class="hit"><td class="line">73</td><td class="hits">122</td><td class="source">		return (code128b[n] ? (code128b[n] + 1000).toString(2) : '');</td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">76</td><td class="hits"></td><td class="source">	// Use the regexp variable for validation</td></tr><tr class="hit"><td class="line">77</td><td class="hits">29</td><td class="source">	this.valid = function() {</td></tr><tr class="hit"><td class="line">78</td><td class="hits">12</td><td class="source">		return !(this.string.search(validCODE128) === -1);</td></tr><tr><td class="line">79</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">81</td><td class="hits">29</td><td class="source">	function nextA(bytes, depth){</td></tr><tr class="hit"><td class="line">82</td><td class="hits">32</td><td class="source">		if(bytes.length &lt;= 0){</td></tr><tr class="hit"><td class="line">83</td><td class="hits">4</td><td class="source">			return {&quot;result&quot;: &quot;&quot;, &quot;checksum&quot;: 0};</td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">86</td><td class="hits">28</td><td class="source">		var next, index;</td></tr><tr><td class="line">87</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source">		// Special characters</td></tr><tr class="hit"><td class="line">89</td><td class="hits">28</td><td class="source">		if(bytes[0] &gt;= 200){</td></tr><tr class="hit"><td class="line">90</td><td class="hits">5</td><td class="source">			index = bytes[0] - 105;</td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source">			//Remove first element</td></tr><tr class="hit"><td class="line">93</td><td class="hits">5</td><td class="source">			bytes.shift();</td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source">			// Swap to CODE128C</td></tr><tr class="hit"><td class="line">96</td><td class="hits">5</td><td class="source">			if(index === 99){</td></tr><tr class="hit"><td class="line">97</td><td class="hits">1</td><td class="source">				next = nextC(bytes, depth + 1);</td></tr><tr><td class="line">98</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">99</td><td class="hits"></td><td class="source">			// Swap to CODE128B</td></tr><tr class="hit"><td class="line">100</td><td class="hits">4</td><td class="source">			else if(index === 100){</td></tr><tr class="hit"><td class="line">101</td><td class="hits">2</td><td class="source">				next = nextB(bytes, depth + 1);</td></tr><tr><td class="line">102</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">103</td><td class="hits"></td><td class="source">			// Shift</td></tr><tr class="hit"><td class="line">104</td><td class="hits">2</td><td class="source">			else if(index === 98){</td></tr><tr><td class="line">105</td><td class="hits"></td><td class="source">				// Convert the next character so that is encoded correctly</td></tr><tr class="hit"><td class="line">106</td><td class="hits">1</td><td class="source">				bytes[0] = bytes[0] &gt; 95 ? bytes[0] - 96 : bytes[0];</td></tr><tr class="hit"><td class="line">107</td><td class="hits">1</td><td class="source">				next = nextA(bytes, depth + 1);</td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source">			// Continue on CODE128A but encode a special character</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source">			else{</td></tr><tr class="hit"><td class="line">111</td><td class="hits">1</td><td class="source">				next = nextA(bytes, depth + 1);</td></tr><tr><td class="line">112</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">113</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">114</td><td class="hits"></td><td class="source">		// Continue encoding of CODE128A</td></tr><tr><td class="line">115</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">116</td><td class="hits">23</td><td class="source">			var charCode = bytes[0];</td></tr><tr class="hit"><td class="line">117</td><td class="hits">23</td><td class="source">			index = charCode &lt; 32 ? charCode + 64 : charCode - 32;</td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">119</td><td class="hits"></td><td class="source">			// Remove first element</td></tr><tr class="hit"><td class="line">120</td><td class="hits">23</td><td class="source">			bytes.shift();</td></tr><tr><td class="line">121</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">122</td><td class="hits">23</td><td class="source">			next = nextA(bytes, depth + 1);</td></tr><tr><td class="line">123</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">124</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">125</td><td class="hits"></td><td class="source">		// Get the correct binary encoding and calculate the weight</td></tr><tr class="hit"><td class="line">126</td><td class="hits">28</td><td class="source">		var enc = getEncoding(index);</td></tr><tr class="hit"><td class="line">127</td><td class="hits">28</td><td class="source">		var weight = index * depth;</td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">129</td><td class="hits">28</td><td class="source">		return {&quot;result&quot;: enc + next.result, &quot;checksum&quot;: weight + next.checksum}</td></tr><tr><td class="line">130</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">131</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">132</td><td class="hits">29</td><td class="source">	function nextB(bytes, depth){</td></tr><tr class="hit"><td class="line">133</td><td class="hits">42</td><td class="source">		if(bytes.length &lt;= 0){</td></tr><tr class="hit"><td class="line">134</td><td class="hits">4</td><td class="source">			return {&quot;result&quot;: &quot;&quot;, &quot;checksum&quot;: 0};</td></tr><tr><td class="line">135</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">136</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">137</td><td class="hits">38</td><td class="source">		var next, index;</td></tr><tr><td class="line">138</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">139</td><td class="hits"></td><td class="source">		// Special characters</td></tr><tr class="hit"><td class="line">140</td><td class="hits">38</td><td class="source">		if(bytes[0] &gt;= 200){</td></tr><tr class="hit"><td class="line">141</td><td class="hits">5</td><td class="source">			index = bytes[0] - 105;</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">143</td><td class="hits"></td><td class="source">			//Remove first element</td></tr><tr class="hit"><td class="line">144</td><td class="hits">5</td><td class="source">			bytes.shift();</td></tr><tr><td class="line">145</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">146</td><td class="hits"></td><td class="source">			// Swap to CODE128C</td></tr><tr class="hit"><td class="line">147</td><td class="hits">5</td><td class="source">			if(index === 99){</td></tr><tr class="hit"><td class="line">148</td><td class="hits">2</td><td class="source">				next = nextC(bytes, depth + 1);</td></tr><tr><td class="line">149</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">150</td><td class="hits"></td><td class="source">			// Swap to CODE128A</td></tr><tr class="hit"><td class="line">151</td><td class="hits">3</td><td class="source">			else if(index === 101){</td></tr><tr class="hit"><td class="line">152</td><td class="hits">1</td><td class="source">				next = nextA(bytes, depth + 1);</td></tr><tr><td class="line">153</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">154</td><td class="hits"></td><td class="source">			// Shift</td></tr><tr class="hit"><td class="line">155</td><td class="hits">2</td><td class="source">			else if(index === 98){</td></tr><tr><td class="line">156</td><td class="hits"></td><td class="source">				// Convert the next character so that is encoded correctly</td></tr><tr class="hit"><td class="line">157</td><td class="hits">1</td><td class="source">				bytes[0] = bytes[0] &lt; 32 ? bytes[0] + 96 : bytes[0];</td></tr><tr class="hit"><td class="line">158</td><td class="hits">1</td><td class="source">				next = nextB(bytes, depth + 1);</td></tr><tr><td class="line">159</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">160</td><td class="hits"></td><td class="source">			// Continue on CODE128B but encode a special character</td></tr><tr><td class="line">161</td><td class="hits"></td><td class="source">			else{</td></tr><tr class="hit"><td class="line">162</td><td class="hits">1</td><td class="source">				next = nextB(bytes, depth + 1);</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">164</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">165</td><td class="hits"></td><td class="source">		// Continue encoding of CODE128B</td></tr><tr><td class="line">166</td><td class="hits"></td><td class="source">		else {</td></tr><tr class="hit"><td class="line">167</td><td class="hits">33</td><td class="source">			index = bytes[0] - 32;</td></tr><tr class="hit"><td class="line">168</td><td class="hits">33</td><td class="source">			bytes.shift();</td></tr><tr class="hit"><td class="line">169</td><td class="hits">33</td><td class="source">			next = nextB(bytes, depth + 1);</td></tr><tr><td class="line">170</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">171</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source">		// Get the correct binary encoding and calculate the weight</td></tr><tr class="hit"><td class="line">173</td><td class="hits">38</td><td class="source">		var enc = getEncoding(index);</td></tr><tr class="hit"><td class="line">174</td><td class="hits">38</td><td class="source">		var weight = index * depth;</td></tr><tr><td class="line">175</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">176</td><td class="hits">38</td><td class="source">		return {&quot;result&quot;: enc + next.result, &quot;checksum&quot;: weight + next.checksum};</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">178</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">179</td><td class="hits">29</td><td class="source">	function nextC(bytes, depth){</td></tr><tr class="hit"><td class="line">180</td><td class="hits">26</td><td class="source">		if(bytes.length &lt;= 0){</td></tr><tr class="hit"><td class="line">181</td><td class="hits">3</td><td class="source">			return {&quot;result&quot;: &quot;&quot;, &quot;checksum&quot;: 0};</td></tr><tr><td class="line">182</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">183</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">184</td><td class="hits">23</td><td class="source">		var next, index;</td></tr><tr><td class="line">185</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">186</td><td class="hits"></td><td class="source">		// Special characters</td></tr><tr class="hit"><td class="line">187</td><td class="hits">23</td><td class="source">		if(bytes[0] &gt;= 200){</td></tr><tr class="hit"><td class="line">188</td><td class="hits">5</td><td class="source">			index = bytes[0] - 105;</td></tr><tr><td class="line">189</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">190</td><td class="hits"></td><td class="source">			// Remove first element</td></tr><tr class="hit"><td class="line">191</td><td class="hits">5</td><td class="source">			bytes.shift();</td></tr><tr><td class="line">192</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">193</td><td class="hits"></td><td class="source">			// Swap to CODE128B</td></tr><tr class="hit"><td class="line">194</td><td class="hits">5</td><td class="source">			if(index === 100){</td></tr><tr class="hit"><td class="line">195</td><td class="hits">1</td><td class="source">				next = nextB(bytes, depth + 1);</td></tr><tr><td class="line">196</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">197</td><td class="hits"></td><td class="source">			// Swap to CODE128A</td></tr><tr class="hit"><td class="line">198</td><td class="hits">4</td><td class="source">			else if(index === 101){</td></tr><tr class="hit"><td class="line">199</td><td class="hits">2</td><td class="source">				next = nextA(bytes, depth + 1);</td></tr><tr><td class="line">200</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">201</td><td class="hits"></td><td class="source">			// Continue on CODE128C but encode a special character</td></tr><tr><td class="line">202</td><td class="hits"></td><td class="source">			else{</td></tr><tr class="hit"><td class="line">203</td><td class="hits">2</td><td class="source">				next = nextC(bytes, depth + 1);</td></tr><tr><td class="line">204</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">205</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">206</td><td class="hits"></td><td class="source">		// Continue encoding of CODE128C</td></tr><tr><td class="line">207</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">208</td><td class="hits">18</td><td class="source">			index = (bytes[0]-48) * 10 + bytes[1]-48;</td></tr><tr class="hit"><td class="line">209</td><td class="hits">18</td><td class="source">			bytes.shift();</td></tr><tr class="hit"><td class="line">210</td><td class="hits">18</td><td class="source">			bytes.shift();</td></tr><tr class="hit"><td class="line">211</td><td class="hits">18</td><td class="source">			next = nextC(bytes, depth + 1);</td></tr><tr><td class="line">212</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">213</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">214</td><td class="hits"></td><td class="source">		// Get the correct binary encoding and calculate the weight</td></tr><tr class="hit"><td class="line">215</td><td class="hits">23</td><td class="source">		var enc = getEncoding(index);</td></tr><tr class="hit"><td class="line">216</td><td class="hits">23</td><td class="source">		var weight = index * depth;</td></tr><tr><td class="line">217</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">218</td><td class="hits">23</td><td class="source">		return {&quot;result&quot;: enc + next.result, &quot;checksum&quot;: weight + next.checksum};</td></tr><tr><td class="line">219</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">220</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">222</td><td class="hits">1</td><td class="source">function autoSelectModes(string){</td></tr><tr><td class="line">223</td><td class="hits"></td><td class="source">	// ASCII ranges 0-98 and 200-207 (FUNCs and SHIFTs)</td></tr><tr class="hit"><td class="line">224</td><td class="hits">18</td><td class="source">	var aLength = string.match(/^[\x00-\x5F\xC8-\xCF]*/)[0].length;</td></tr><tr><td class="line">225</td><td class="hits"></td><td class="source">	// ASCII ranges 32-127 and 200-207 (FUNCs and SHIFTs)</td></tr><tr class="hit"><td class="line">226</td><td class="hits">18</td><td class="source">	var bLength = string.match(/^[\x20-\x7F\xC8-\xCF]*/)[0].length;</td></tr><tr><td class="line">227</td><td class="hits"></td><td class="source">	// Number pairs or [FNC1]</td></tr><tr class="hit"><td class="line">228</td><td class="hits">18</td><td class="source">	var cLength = string.match(/^(\xCF*[0-9]{2}\xCF*)*/)[0].length;</td></tr><tr><td class="line">229</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">230</td><td class="hits">18</td><td class="source">	var newString;</td></tr><tr><td class="line">231</td><td class="hits"></td><td class="source">	// Select CODE128C if the string start with enough digits</td></tr><tr class="hit"><td class="line">232</td><td class="hits">18</td><td class="source">	if(cLength &gt;= 2){</td></tr><tr class="hit"><td class="line">233</td><td class="hits">2</td><td class="source">		 newString = String.fromCharCode(210) + autoSelectFromC(string);</td></tr><tr><td class="line">234</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">235</td><td class="hits"></td><td class="source">	// Select A/C depending on the longest match</td></tr><tr class="hit"><td class="line">236</td><td class="hits">16</td><td class="source">	else if(aLength &gt; bLength){</td></tr><tr class="hit"><td class="line">237</td><td class="hits">3</td><td class="source">		newString = String.fromCharCode(208) + autoSelectFromA(string);</td></tr><tr><td class="line">238</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">239</td><td class="hits"></td><td class="source">	else{</td></tr><tr class="hit"><td class="line">240</td><td class="hits">13</td><td class="source">		newString = String.fromCharCode(209) + autoSelectFromB(string);</td></tr><tr><td class="line">241</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">242</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">243</td><td class="hits">18</td><td class="source">	newString = newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, function(match, char){</td></tr><tr class="hit"><td class="line">244</td><td class="hits">2</td><td class="source">		return String.fromCharCode(203) + char;</td></tr><tr><td class="line">245</td><td class="hits"></td><td class="source">	});</td></tr><tr><td class="line">246</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">247</td><td class="hits">18</td><td class="source">	return newString;</td></tr><tr><td class="line">248</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">249</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">250</td><td class="hits">1</td><td class="source">function autoSelectFromA(string){</td></tr><tr class="hit"><td class="line">251</td><td class="hits">8</td><td class="source">	var untilC = string.match(/^([\x00-\x5F\xC8-\xCF]+?)(([0-9]{2}){2,})([^0-9]|$)/);</td></tr><tr><td class="line">252</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">253</td><td class="hits">8</td><td class="source">	if(untilC){</td></tr><tr class="hit"><td class="line">254</td><td class="hits">1</td><td class="source">		return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));</td></tr><tr><td class="line">255</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">256</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">257</td><td class="hits">7</td><td class="source">	var aChars = string.match(/^[\x00-\x5F\xC8-\xCF]+/);</td></tr><tr class="hit"><td class="line">258</td><td class="hits">7</td><td class="source">	if(aChars[0].length === string.length){</td></tr><tr class="hit"><td class="line">259</td><td class="hits">3</td><td class="source">		return string;</td></tr><tr><td class="line">260</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">261</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">262</td><td class="hits">4</td><td class="source">	return aChars[0] + String.fromCharCode(205) + autoSelectFromB(string.substring(aChars[0].length));</td></tr><tr><td class="line">263</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">264</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">265</td><td class="hits">1</td><td class="source">function autoSelectFromB(string){</td></tr><tr class="hit"><td class="line">266</td><td class="hits">18</td><td class="source">	var untilC = string.match(/^([\x20-\x7F\xC8-\xCF]+?)(([0-9]{2}){2,})([^0-9]|$)/);</td></tr><tr><td class="line">267</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">268</td><td class="hits">18</td><td class="source">	if(untilC){</td></tr><tr class="hit"><td class="line">269</td><td class="hits">2</td><td class="source">		return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));</td></tr><tr><td class="line">270</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">271</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">272</td><td class="hits">16</td><td class="source">	var bChars = string.match(/^[\x20-\x7F\xC8-\xCF]+/);</td></tr><tr class="hit"><td class="line">273</td><td class="hits">16</td><td class="source">	if(bChars[0].length === string.length){</td></tr><tr class="hit"><td class="line">274</td><td class="hits">13</td><td class="source">		return string;</td></tr><tr><td class="line">275</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">276</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">277</td><td class="hits">3</td><td class="source">	return bChars[0] + String.fromCharCode(206) + autoSelectFromA(string.substring(bChars[0].length));</td></tr><tr><td class="line">278</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">279</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">280</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">281</td><td class="hits">1</td><td class="source">function autoSelectFromC(string){</td></tr><tr class="hit"><td class="line">282</td><td class="hits">5</td><td class="source">	var cMatch = string.match(/^(\xCF*[0-9]{2}\xCF*)+/)[0];</td></tr><tr class="hit"><td class="line">283</td><td class="hits">5</td><td class="source">	var length = cMatch.length;</td></tr><tr><td class="line">284</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">285</td><td class="hits">5</td><td class="source">	if(length === string.length){</td></tr><tr class="hit"><td class="line">286</td><td class="hits">2</td><td class="source">		return string;</td></tr><tr><td class="line">287</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">288</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">289</td><td class="hits">3</td><td class="source">	string = string.substring(length);</td></tr><tr><td class="line">290</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">291</td><td class="hits"></td><td class="source">	// Select A/B depending on the longest match</td></tr><tr class="hit"><td class="line">292</td><td class="hits">3</td><td class="source">	var aLength = string.match(/^[\x00-\x5F\xC8-\xCF]*/)[0].length;</td></tr><tr class="hit"><td class="line">293</td><td class="hits">3</td><td class="source">	var bLength = string.match(/^[\x20-\x7F\xC8-\xCF]*/)[0].length;</td></tr><tr class="hit"><td class="line">294</td><td class="hits">3</td><td class="source">	if(aLength &gt;= bLength){</td></tr><tr class="hit"><td class="line">295</td><td class="hits">2</td><td class="source">		return cMatch + String.fromCharCode(206) + autoSelectFromA(string);</td></tr><tr><td class="line">296</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">297</td><td class="hits"></td><td class="source">	else{</td></tr><tr class="hit"><td class="line">298</td><td class="hits">1</td><td class="source">		return cMatch + String.fromCharCode(205) + autoSelectFromB(string);</td></tr><tr><td class="line">299</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">300</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">301</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">302</td><td class="hits">1</td><td class="source">function CODE128AUTO(string) {</td></tr><tr><td class="line">303</td><td class="hits"></td><td class="source">	// Check the validity of the string, don't even bother auto it when</td></tr><tr><td class="line">304</td><td class="hits"></td><td class="source">	//it's not valid</td></tr><tr class="hit"><td class="line">305</td><td class="hits">19</td><td class="source">	if(string.search(validCODE128) !== -1){</td></tr><tr class="hit"><td class="line">306</td><td class="hits">18</td><td class="source">		return new CODE128(autoSelectModes(string));</td></tr><tr><td class="line">307</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">308</td><td class="hits">1</td><td class="source">	return new CODE128(string);</td></tr><tr><td class="line">309</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">310</td><td class="hits">1</td><td class="source">function CODE128A(string) {</td></tr><tr class="hit"><td class="line">311</td><td class="hits">3</td><td class="source">	var code128 = new CODE128(String.fromCharCode(208) + string);</td></tr><tr class="hit"><td class="line">312</td><td class="hits">3</td><td class="source">	code128.valid = function(){</td></tr><tr class="hit"><td class="line">313</td><td class="hits">2</td><td class="source">		return this.string.search(/^[\x00-\x5F\xC8-\xCF]+$/) !== -1;</td></tr><tr><td class="line">314</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">315</td><td class="hits">3</td><td class="source">	return code128;</td></tr><tr><td class="line">316</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">317</td><td class="hits">1</td><td class="source">function CODE128B(string) {</td></tr><tr class="hit"><td class="line">318</td><td class="hits">3</td><td class="source">	var code128 = new CODE128(String.fromCharCode(209) + string);</td></tr><tr class="hit"><td class="line">319</td><td class="hits">3</td><td class="source">	code128.valid = function(){</td></tr><tr class="hit"><td class="line">320</td><td class="hits">2</td><td class="source">		return this.string.search(/^[\x20-\x7F\xC8-\xCF]+$/) !== -1;</td></tr><tr><td class="line">321</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">322</td><td class="hits">3</td><td class="source">	return code128;</td></tr><tr><td class="line">323</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">324</td><td class="hits">1</td><td class="source">function CODE128C(string) {</td></tr><tr class="hit"><td class="line">325</td><td class="hits">4</td><td class="source">	var code128 = new CODE128(String.fromCharCode(210) + string);</td></tr><tr class="hit"><td class="line">326</td><td class="hits">4</td><td class="source">	code128.valid = function(str){</td></tr><tr class="hit"><td class="line">327</td><td class="hits">3</td><td class="source">		return this.string.search(/^(\xCF*[0-9]{2}\xCF*)+$/) !== -1;</td></tr><tr><td class="line">328</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">329</td><td class="hits">4</td><td class="source">	return code128;</td></tr><tr><td class="line">330</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">331</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">332</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">333</td><td class="hits">1</td><td class="source">var register = function(core) {</td></tr><tr class="hit"><td class="line">334</td><td class="hits">1</td><td class="source">	core.register(CODE128AUTO, /^CODE128(.?AUTO)?$/, 10);</td></tr><tr class="hit"><td class="line">335</td><td class="hits">1</td><td class="source">	core.register(CODE128A, /^CODE128.?A$/i, 2);</td></tr><tr class="hit"><td class="line">336</td><td class="hits">1</td><td class="source">	core.register(CODE128B, /^CODE128.?B$/i, 3);</td></tr><tr class="hit"><td class="line">337</td><td class="hits">1</td><td class="source">	core.register(CODE128C, /^CODE128.?C$/i, 2);</td></tr><tr><td class="line">338</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">339</td><td class="hits">2</td><td class="source">try {register(JsBarcode)} catch(e) {}</td></tr><tr class="hit"><td class="line">340</td><td class="hits">2</td><td class="source">try {module.exports.register = register} catch(e) {}</td></tr><tr><td class="line">341</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/CODE39.js">/home/johan/DevZone/JsBarcode/barcodes/CODE39.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">18</div><div class="hits">18</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">function CODE39(string){</td></tr><tr class="hit"><td class="line">2</td><td class="hits">9</td><td class="source">	this.string = string.toUpperCase();</td></tr><tr><td class="line">3</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">4</td><td class="hits">9</td><td class="source">	var encodings = {</td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source">		&quot;0&quot;: 20957, &quot;1&quot;: 29783, &quot;2&quot;: 23639, &quot;3&quot;: 30485,</td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source">		&quot;4&quot;: 20951, &quot;5&quot;: 29813, &quot;6&quot;: 23669, &quot;7&quot;: 20855,</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source">		&quot;8&quot;: 29789, &quot;9&quot;: 23645, &quot;A&quot;: 29975, &quot;B&quot;: 23831,</td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source">		&quot;C&quot;: 30533, &quot;D&quot;: 22295, &quot;E&quot;: 30149, &quot;F&quot;: 24005,</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source">		&quot;G&quot;: 21623, &quot;H&quot;: 29981, &quot;I&quot;: 23837, &quot;J&quot;: 22301,</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source">		&quot;K&quot;: 30023, &quot;L&quot;: 23879, &quot;M&quot;: 30545, &quot;N&quot;: 22343,</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">		&quot;O&quot;: 30161, &quot;P&quot;: 24017, &quot;Q&quot;: 21959, &quot;R&quot;: 30065,</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source">		&quot;S&quot;: 23921, &quot;T&quot;: 22385, &quot;U&quot;: 29015, &quot;V&quot;: 18263,</td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source">		&quot;W&quot;: 29141, &quot;X&quot;: 17879, &quot;Y&quot;: 29045, &quot;Z&quot;: 18293,</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source">		&quot;-&quot;: 17783, &quot;.&quot;: 29021, &quot; &quot;: 18269, &quot;$&quot;: 17477,</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source">		&quot;/&quot;: 17489, &quot;+&quot;: 17681, &quot;%&quot;: 20753, &quot;*&quot;: 35770</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">19</td><td class="hits">9</td><td class="source">	this.getText = function(){</td></tr><tr class="hit"><td class="line">20</td><td class="hits">9</td><td class="source">		return this.string;</td></tr><tr><td class="line">21</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">23</td><td class="hits">9</td><td class="source">	this.encoded = function(){</td></tr><tr class="hit"><td class="line">24</td><td class="hits">5</td><td class="source">		var result = &quot;&quot;;</td></tr><tr class="hit"><td class="line">25</td><td class="hits">5</td><td class="source">		result += encodings[&quot;*&quot;].toString(2);</td></tr><tr class="hit"><td class="line">26</td><td class="hits">5</td><td class="source">		for(var i=0; i&lt;this.string.length; i++){</td></tr><tr class="hit"><td class="line">27</td><td class="hits">24</td><td class="source">			result += encodings[this.string[i]].toString(2) + &quot;0&quot;;</td></tr><tr><td class="line">28</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">29</td><td class="hits">5</td><td class="source">		result += encodings[&quot;*&quot;].toString(2);</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">31</td><td class="hits">5</td><td class="source">		return result;</td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source">	//Use the regexp variable for validation</td></tr><tr class="hit"><td class="line">35</td><td class="hits">9</td><td class="source">	this.valid = function(){</td></tr><tr class="hit"><td class="line">36</td><td class="hits">7</td><td class="source">		return this.string.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">42</td><td class="hits">1</td><td class="source">var register = function(core){</td></tr><tr class="hit"><td class="line">43</td><td class="hits">1</td><td class="source">	core.register(CODE39, /^CODE.?39$/i, 3);</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">};</td></tr><tr class="hit"><td class="line">45</td><td class="hits">2</td><td class="source">try{register(JsBarcode)} catch(e){}</td></tr><tr class="hit"><td class="line">46</td><td class="hits">2</td><td class="source">try{module.exports.register = register} catch(e){}</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/EAN_UPC.js">/home/johan/DevZone/JsBarcode/barcodes/EAN_UPC.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">99</div><div class="hits">99</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">function EAN(EANnumber){</td></tr><tr class="hit"><td class="line">2</td><td class="hits">15</td><td class="source">	this.EANnumber = EANnumber+&quot;&quot;;</td></tr><tr><td class="line">3</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source">	//Regexp to test if the EAN code is correct formated</td></tr><tr class="hit"><td class="line">5</td><td class="hits">15</td><td class="source">	var fullEanRegexp = /^[0-9]{13}$/;</td></tr><tr class="hit"><td class="line">6</td><td class="hits">15</td><td class="source">	var needLastDigitRegexp = /^[0-9]{12}$/;</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source">	//Add checksum if it does not exist</td></tr><tr class="hit"><td class="line">9</td><td class="hits">15</td><td class="source">	if(this.EANnumber.search(needLastDigitRegexp)!=-1){</td></tr><tr class="hit"><td class="line">10</td><td class="hits">2</td><td class="source">		this.EANnumber += checksum(this.EANnumber);</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">13</td><td class="hits">15</td><td class="source">	this.getText = function(){</td></tr><tr class="hit"><td class="line">14</td><td class="hits">6</td><td class="source">		return this.EANnumber;</td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">17</td><td class="hits">15</td><td class="source">	this.valid = function(){</td></tr><tr class="hit"><td class="line">18</td><td class="hits">12</td><td class="source">		return valid(this.EANnumber);</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">21</td><td class="hits">15</td><td class="source">	this.encoded = function (){</td></tr><tr class="hit"><td class="line">22</td><td class="hits">4</td><td class="source">		return createEAN13(this.EANnumber);</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">	//Create the binary representation of the EAN code</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source">	//number needs to be a string</td></tr><tr class="hit"><td class="line">27</td><td class="hits">15</td><td class="source">	function createEAN13(number){</td></tr><tr class="hit"><td class="line">28</td><td class="hits">4</td><td class="source">		var encoder = new EANencoder();</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source">		//Create the return variable</td></tr><tr class="hit"><td class="line">31</td><td class="hits">4</td><td class="source">		var result = &quot;&quot;;</td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">33</td><td class="hits">4</td><td class="source">		var structure = encoder.getEANstructure(number);</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">		//Get the number to be encoded on the left side of the EAN code</td></tr><tr class="hit"><td class="line">36</td><td class="hits">4</td><td class="source">		var leftSide = number.substr(1,7);</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">		//Get the number to be encoded on the right side of the EAN code</td></tr><tr class="hit"><td class="line">39</td><td class="hits">4</td><td class="source">		var rightSide = number.substr(7,6);</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">		//Add the start bits</td></tr><tr class="hit"><td class="line">42</td><td class="hits">4</td><td class="source">		result += encoder.startBin;</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">		//Add the left side</td></tr><tr class="hit"><td class="line">45</td><td class="hits">4</td><td class="source">		result += encoder.encode(leftSide, structure);</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source">		//Add the middle bits</td></tr><tr class="hit"><td class="line">48</td><td class="hits">4</td><td class="source">		result += encoder.middleBin;</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">		//Add the right side</td></tr><tr class="hit"><td class="line">51</td><td class="hits">4</td><td class="source">		result += encoder.encode(rightSide,&quot;RRRRRR&quot;);</td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">53</td><td class="hits"></td><td class="source">		//Add the end bits</td></tr><tr class="hit"><td class="line">54</td><td class="hits">4</td><td class="source">		result += encoder.endBin;</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">56</td><td class="hits">4</td><td class="source">		return result;</td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">	//Calulate the checksum digit</td></tr><tr class="hit"><td class="line">60</td><td class="hits">15</td><td class="source">	function checksum(number){</td></tr><tr class="hit"><td class="line">61</td><td class="hits">6</td><td class="source">		var result = 0;</td></tr><tr><td class="line">62</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">63</td><td class="hits">42</td><td class="source">		for(var i=0;i&lt;12;i+=2){result+=parseInt(number[i])}</td></tr><tr class="hit"><td class="line">64</td><td class="hits">42</td><td class="source">		for(var i=1;i&lt;12;i+=2){result+=parseInt(number[i])*3}</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">66</td><td class="hits">6</td><td class="source">		return (10 - (result % 10)) % 10;</td></tr><tr><td class="line">67</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">69</td><td class="hits">15</td><td class="source">	function valid(number){</td></tr><tr class="hit"><td class="line">70</td><td class="hits">12</td><td class="source">		if(number.search(fullEanRegexp)!=-1){</td></tr><tr class="hit"><td class="line">71</td><td class="hits">4</td><td class="source">			return number[12] == checksum(number);</td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">74</td><td class="hits">8</td><td class="source">			return false;</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">76</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">79</td><td class="hits">1</td><td class="source">function EAN8(EAN8number){</td></tr><tr class="hit"><td class="line">80</td><td class="hits">8</td><td class="source">	this.EAN8number = EAN8number+&quot;&quot;;</td></tr><tr><td class="line">81</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source">	//Regexp to test if the EAN code is correct formated</td></tr><tr class="hit"><td class="line">83</td><td class="hits">8</td><td class="source">	var fullEanRegexp = /^[0-9]{8}$/;</td></tr><tr class="hit"><td class="line">84</td><td class="hits">8</td><td class="source">	var needLastDigitRegexp = /^[0-9]{7}$/;</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">86</td><td class="hits"></td><td class="source">	//Add checksum if it does not exist</td></tr><tr class="hit"><td class="line">87</td><td class="hits">8</td><td class="source">	if(this.EAN8number.search(needLastDigitRegexp)!=-1){</td></tr><tr class="hit"><td class="line">88</td><td class="hits">1</td><td class="source">		this.EAN8number += checksum(this.EAN8number);</td></tr><tr><td class="line">89</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">91</td><td class="hits">8</td><td class="source">	this.getText = function(){</td></tr><tr class="hit"><td class="line">92</td><td class="hits">1</td><td class="source">		return this.EAN8number;</td></tr><tr><td class="line">93</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">95</td><td class="hits">8</td><td class="source">	this.valid = function(){</td></tr><tr class="hit"><td class="line">96</td><td class="hits">8</td><td class="source">		return valid(this.EAN8number);</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">98</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">99</td><td class="hits">8</td><td class="source">	this.encoded = function (){</td></tr><tr class="hit"><td class="line">100</td><td class="hits">2</td><td class="source">		return createEAN8(this.EAN8number);</td></tr><tr><td class="line">101</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">102</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">103</td><td class="hits">8</td><td class="source">	function valid(number){</td></tr><tr class="hit"><td class="line">104</td><td class="hits">8</td><td class="source">		if(number.search(fullEanRegexp)!=-1){</td></tr><tr class="hit"><td class="line">105</td><td class="hits">3</td><td class="source">			return number[7] == checksum(number);</td></tr><tr><td class="line">106</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">107</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">108</td><td class="hits">5</td><td class="source">			return false;</td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">110</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">111</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">112</td><td class="hits"></td><td class="source">	//Calulate the checksum digit</td></tr><tr class="hit"><td class="line">113</td><td class="hits">8</td><td class="source">	function checksum(number){</td></tr><tr class="hit"><td class="line">114</td><td class="hits">4</td><td class="source">		var result = 0;</td></tr><tr><td class="line">115</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">116</td><td class="hits">20</td><td class="source">		for(var i=0;i&lt;7;i+=2){result+=parseInt(number[i])*3}</td></tr><tr class="hit"><td class="line">117</td><td class="hits">16</td><td class="source">		for(var i=1;i&lt;7;i+=2){result+=parseInt(number[i])}</td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">119</td><td class="hits">4</td><td class="source">		return (10 - (result % 10)) % 10;</td></tr><tr><td class="line">120</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">121</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">122</td><td class="hits">8</td><td class="source">	function createEAN8(number){</td></tr><tr class="hit"><td class="line">123</td><td class="hits">2</td><td class="source">		var encoder = new EANencoder();</td></tr><tr><td class="line">124</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">125</td><td class="hits"></td><td class="source">		//Create the return variable</td></tr><tr class="hit"><td class="line">126</td><td class="hits">2</td><td class="source">		var result = &quot;&quot;;</td></tr><tr><td class="line">127</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source">		//Get the number to be encoded on the left side of the EAN code</td></tr><tr class="hit"><td class="line">129</td><td class="hits">2</td><td class="source">		var leftSide = number.substr(0,4);</td></tr><tr><td class="line">130</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">131</td><td class="hits"></td><td class="source">		//Get the number to be encoded on the right side of the EAN code</td></tr><tr class="hit"><td class="line">132</td><td class="hits">2</td><td class="source">		var rightSide = number.substr(4,4);</td></tr><tr><td class="line">133</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">134</td><td class="hits"></td><td class="source">		//Add the start bits</td></tr><tr class="hit"><td class="line">135</td><td class="hits">2</td><td class="source">		result += encoder.startBin;</td></tr><tr><td class="line">136</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">137</td><td class="hits"></td><td class="source">		//Add the left side</td></tr><tr class="hit"><td class="line">138</td><td class="hits">2</td><td class="source">		result += encoder.encode(leftSide, &quot;LLLL&quot;);</td></tr><tr><td class="line">139</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">140</td><td class="hits"></td><td class="source">		//Add the middle bits</td></tr><tr class="hit"><td class="line">141</td><td class="hits">2</td><td class="source">		result += encoder.middleBin;</td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">143</td><td class="hits"></td><td class="source">		//Add the right side</td></tr><tr class="hit"><td class="line">144</td><td class="hits">2</td><td class="source">		result += encoder.encode(rightSide,&quot;RRRR&quot;);</td></tr><tr><td class="line">145</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">146</td><td class="hits"></td><td class="source">		//Add the end bits</td></tr><tr class="hit"><td class="line">147</td><td class="hits">2</td><td class="source">		result += encoder.endBin;</td></tr><tr><td class="line">148</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">149</td><td class="hits">2</td><td class="source">		return result;</td></tr><tr><td class="line">150</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">151</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">152</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">153</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">154</td><td class="hits">1</td><td class="source">function UPC(UPCnumber){</td></tr><tr class="hit"><td class="line">155</td><td class="hits">6</td><td class="source">	this.ean = new EAN(&quot;0&quot;+UPCnumber);</td></tr><tr><td class="line">156</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">157</td><td class="hits">6</td><td class="source">	this.getText = function(){</td></tr><tr class="hit"><td class="line">158</td><td class="hits">1</td><td class="source">		return this.ean.getText().substring(1);</td></tr><tr><td class="line">159</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">160</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">161</td><td class="hits">6</td><td class="source">	this.valid = function(){</td></tr><tr class="hit"><td class="line">162</td><td class="hits">4</td><td class="source">		return this.ean.valid();</td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">164</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">165</td><td class="hits">6</td><td class="source">	this.encoded = function(){</td></tr><tr class="hit"><td class="line">166</td><td class="hits">1</td><td class="source">		return this.ean.encoded();</td></tr><tr><td class="line">167</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">168</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">169</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">170</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">171</td><td class="hits"></td><td class="source">//</td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source">// Help class that does all the encoding</td></tr><tr><td class="line">173</td><td class="hits"></td><td class="source">//</td></tr><tr class="hit"><td class="line">174</td><td class="hits">1</td><td class="source">function EANencoder(){</td></tr><tr><td class="line">175</td><td class="hits"></td><td class="source">	//The start bits</td></tr><tr class="hit"><td class="line">176</td><td class="hits">6</td><td class="source">	this.startBin = &quot;101&quot;;</td></tr><tr><td class="line">177</td><td class="hits"></td><td class="source">	//The end bits</td></tr><tr class="hit"><td class="line">178</td><td class="hits">6</td><td class="source">	this.endBin = &quot;101&quot;;</td></tr><tr><td class="line">179</td><td class="hits"></td><td class="source">	//The middle bits</td></tr><tr class="hit"><td class="line">180</td><td class="hits">6</td><td class="source">	this.middleBin = &quot;01010&quot;;</td></tr><tr><td class="line">181</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">182</td><td class="hits"></td><td class="source">	//The L (left) type of encoding</td></tr><tr class="hit"><td class="line">183</td><td class="hits">6</td><td class="source">	var Lbinary = {</td></tr><tr><td class="line">184</td><td class="hits"></td><td class="source">	0: &quot;0001101&quot;,</td></tr><tr><td class="line">185</td><td class="hits"></td><td class="source">	1: &quot;0011001&quot;,</td></tr><tr><td class="line">186</td><td class="hits"></td><td class="source">	2: &quot;0010011&quot;,</td></tr><tr><td class="line">187</td><td class="hits"></td><td class="source">	3: &quot;0111101&quot;,</td></tr><tr><td class="line">188</td><td class="hits"></td><td class="source">	4: &quot;0100011&quot;,</td></tr><tr><td class="line">189</td><td class="hits"></td><td class="source">	5: &quot;0110001&quot;,</td></tr><tr><td class="line">190</td><td class="hits"></td><td class="source">	6: &quot;0101111&quot;,</td></tr><tr><td class="line">191</td><td class="hits"></td><td class="source">	7: &quot;0111011&quot;,</td></tr><tr><td class="line">192</td><td class="hits"></td><td class="source">	8: &quot;0110111&quot;,</td></tr><tr><td class="line">193</td><td class="hits"></td><td class="source">	9: &quot;0001011&quot;};</td></tr><tr><td class="line">194</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">195</td><td class="hits"></td><td class="source">	//The G type of encoding</td></tr><tr class="hit"><td class="line">196</td><td class="hits">6</td><td class="source">	var Gbinary = {</td></tr><tr><td class="line">197</td><td class="hits"></td><td class="source">	0: &quot;0100111&quot;,</td></tr><tr><td class="line">198</td><td class="hits"></td><td class="source">	1: &quot;0110011&quot;,</td></tr><tr><td class="line">199</td><td class="hits"></td><td class="source">	2: &quot;0011011&quot;,</td></tr><tr><td class="line">200</td><td class="hits"></td><td class="source">	3: &quot;0100001&quot;,</td></tr><tr><td class="line">201</td><td class="hits"></td><td class="source">	4: &quot;0011101&quot;,</td></tr><tr><td class="line">202</td><td class="hits"></td><td class="source">	5: &quot;0111001&quot;,</td></tr><tr><td class="line">203</td><td class="hits"></td><td class="source">	6: &quot;0000101&quot;,</td></tr><tr><td class="line">204</td><td class="hits"></td><td class="source">	7: &quot;0010001&quot;,</td></tr><tr><td class="line">205</td><td class="hits"></td><td class="source">	8: &quot;0001001&quot;,</td></tr><tr><td class="line">206</td><td class="hits"></td><td class="source">	9: &quot;0010111&quot;};</td></tr><tr><td class="line">207</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">208</td><td class="hits"></td><td class="source">	//The R (right) type of encoding</td></tr><tr class="hit"><td class="line">209</td><td class="hits">6</td><td class="source">	var Rbinary = {</td></tr><tr><td class="line">210</td><td class="hits"></td><td class="source">	0: &quot;1110010&quot;,</td></tr><tr><td class="line">211</td><td class="hits"></td><td class="source">	1: &quot;1100110&quot;,</td></tr><tr><td class="line">212</td><td class="hits"></td><td class="source">	2: &quot;1101100&quot;,</td></tr><tr><td class="line">213</td><td class="hits"></td><td class="source">	3: &quot;1000010&quot;,</td></tr><tr><td class="line">214</td><td class="hits"></td><td class="source">	4: &quot;1011100&quot;,</td></tr><tr><td class="line">215</td><td class="hits"></td><td class="source">	5: &quot;1001110&quot;,</td></tr><tr><td class="line">216</td><td class="hits"></td><td class="source">	6: &quot;1010000&quot;,</td></tr><tr><td class="line">217</td><td class="hits"></td><td class="source">	7: &quot;1000100&quot;,</td></tr><tr><td class="line">218</td><td class="hits"></td><td class="source">	8: &quot;1001000&quot;,</td></tr><tr><td class="line">219</td><td class="hits"></td><td class="source">	9: &quot;1110100&quot;};</td></tr><tr><td class="line">220</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source">	//The left side structure in EAN-13</td></tr><tr class="hit"><td class="line">222</td><td class="hits">6</td><td class="source">	var EANstructure = {</td></tr><tr><td class="line">223</td><td class="hits"></td><td class="source">	0: &quot;LLLLLL&quot;,</td></tr><tr><td class="line">224</td><td class="hits"></td><td class="source">	1: &quot;LLGLGG&quot;,</td></tr><tr><td class="line">225</td><td class="hits"></td><td class="source">	2: &quot;LLGGLG&quot;,</td></tr><tr><td class="line">226</td><td class="hits"></td><td class="source">	3: &quot;LLGGGL&quot;,</td></tr><tr><td class="line">227</td><td class="hits"></td><td class="source">	4: &quot;LGLLGG&quot;,</td></tr><tr><td class="line">228</td><td class="hits"></td><td class="source">	5: &quot;LGGLLG&quot;,</td></tr><tr><td class="line">229</td><td class="hits"></td><td class="source">	6: &quot;LGGGLL&quot;,</td></tr><tr><td class="line">230</td><td class="hits"></td><td class="source">	7: &quot;LGLGLG&quot;,</td></tr><tr><td class="line">231</td><td class="hits"></td><td class="source">	8: &quot;LGLGGL&quot;,</td></tr><tr><td class="line">232</td><td class="hits"></td><td class="source">	9: &quot;LGGLGL&quot;}</td></tr><tr><td class="line">233</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">234</td><td class="hits">6</td><td class="source">	this.getEANstructure = function(number){</td></tr><tr class="hit"><td class="line">235</td><td class="hits">4</td><td class="source">		return EANstructure[number[0]];</td></tr><tr><td class="line">236</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">237</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">238</td><td class="hits"></td><td class="source">	//Convert a numberarray to the representing</td></tr><tr class="hit"><td class="line">239</td><td class="hits">6</td><td class="source">	this.encode = function(number,structure){</td></tr><tr><td class="line">240</td><td class="hits"></td><td class="source">		//Create the variable that should be returned at the end of the function</td></tr><tr class="hit"><td class="line">241</td><td class="hits">12</td><td class="source">		var result = &quot;&quot;;</td></tr><tr><td class="line">242</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">243</td><td class="hits"></td><td class="source">		//Loop all the numbers</td></tr><tr class="hit"><td class="line">244</td><td class="hits">12</td><td class="source">		for(var i = 0;i&lt;number.length;i++){</td></tr><tr><td class="line">245</td><td class="hits"></td><td class="source">			//Using the L, G or R encoding and add it to the returning variable</td></tr><tr class="hit"><td class="line">246</td><td class="hits">68</td><td class="source">			if(structure[i]==&quot;L&quot;){</td></tr><tr class="hit"><td class="line">247</td><td class="hits">23</td><td class="source">				result += Lbinary[number[i]];</td></tr><tr><td class="line">248</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">249</td><td class="hits">45</td><td class="source">			else if(structure[i]==&quot;G&quot;){</td></tr><tr class="hit"><td class="line">250</td><td class="hits">9</td><td class="source">				result += Gbinary[number[i]];</td></tr><tr><td class="line">251</td><td class="hits"></td><td class="source">			}</td></tr><tr class="hit"><td class="line">252</td><td class="hits">36</td><td class="source">			else if(structure[i]==&quot;R&quot;){</td></tr><tr class="hit"><td class="line">253</td><td class="hits">32</td><td class="source">				result += Rbinary[number[i]];</td></tr><tr><td class="line">254</td><td class="hits"></td><td class="source">			}</td></tr><tr><td class="line">255</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">256</td><td class="hits">12</td><td class="source">		return result;</td></tr><tr><td class="line">257</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">258</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">259</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">260</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">261</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">262</td><td class="hits">1</td><td class="source">var register = function(core){</td></tr><tr class="hit"><td class="line">263</td><td class="hits">1</td><td class="source">	core.register(EAN, /^EAN(.?13)?$/i, 8);</td></tr><tr class="hit"><td class="line">264</td><td class="hits">1</td><td class="source">	core.register(EAN8, /^EAN.?8$/i, 8);</td></tr><tr class="hit"><td class="line">265</td><td class="hits">1</td><td class="source">	core.register(UPC, /^UPC(.?A)?$/i, 8);</td></tr><tr><td class="line">266</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">267</td><td class="hits">2</td><td class="source">try{register(JsBarcode)} catch(e){}</td></tr><tr class="hit"><td class="line">268</td><td class="hits">2</td><td class="source">try{module.exports.register = register} catch(e){}</td></tr><tr><td class="line">269</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/ITF.js">/home/johan/DevZone/JsBarcode/barcodes/ITF.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">31</div><div class="hits">31</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">function ITF(ITFNumber){</td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">3</td><td class="hits">6</td><td class="source">	this.ITFNumber = ITFNumber+&quot;&quot;;</td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">5</td><td class="hits">6</td><td class="source">	this.getText = function(){</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">		return this.ITFNumber;</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">9</td><td class="hits">6</td><td class="source">	this.valid = function(){</td></tr><tr class="hit"><td class="line">10</td><td class="hits">4</td><td class="source">		return valid(this.ITFNumber);</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">	};</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">13</td><td class="hits">6</td><td class="source">	this.encoded = function(){</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source">		//Create the variable that should be returned at the end of the function</td></tr><tr class="hit"><td class="line">15</td><td class="hits">1</td><td class="source">		var result = &quot;&quot;;</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source">		//Always add the same start bits</td></tr><tr class="hit"><td class="line">18</td><td class="hits">1</td><td class="source">		result += startBin;</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source">		//Calculate all the digit pairs</td></tr><tr class="hit"><td class="line">21</td><td class="hits">1</td><td class="source">		for(var i=0;i&lt;this.ITFNumber.length;i+=2){</td></tr><tr class="hit"><td class="line">22</td><td class="hits">3</td><td class="source">			result += calculatePair(this.ITFNumber.substr(i,2));</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">		//Always add the same end bits</td></tr><tr class="hit"><td class="line">26</td><td class="hits">1</td><td class="source">		result += endBin;</td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">28</td><td class="hits">1</td><td class="source">		return result;</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">31</td><td class="hits"></td><td class="source">	//The structure for the all digits, 1 is wide and 0 is narrow</td></tr><tr class="hit"><td class="line">32</td><td class="hits">6</td><td class="source">	var digitStructure = {</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source">	 &quot;0&quot;:&quot;00110&quot;</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source">	,&quot;1&quot;:&quot;10001&quot;</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">	,&quot;2&quot;:&quot;01001&quot;</td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">	,&quot;3&quot;:&quot;11000&quot;</td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source">	,&quot;4&quot;:&quot;00101&quot;</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source">	,&quot;5&quot;:&quot;10100&quot;</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source">	,&quot;6&quot;:&quot;01100&quot;</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">	,&quot;7&quot;:&quot;00011&quot;</td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">	,&quot;8&quot;:&quot;10010&quot;</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source">	,&quot;9&quot;:&quot;01010&quot;}</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">	//The start bits</td></tr><tr class="hit"><td class="line">45</td><td class="hits">6</td><td class="source">	var startBin = &quot;1010&quot;;</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">	//The end bits</td></tr><tr class="hit"><td class="line">47</td><td class="hits">6</td><td class="source">	var endBin = &quot;11101&quot;;</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">	//Regexp for a valid Inter25 code</td></tr><tr class="hit"><td class="line">50</td><td class="hits">6</td><td class="source">	var regexp = /^([0-9][0-9])+$/;</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source">	//Calculate the data of a number pair</td></tr><tr class="hit"><td class="line">53</td><td class="hits">6</td><td class="source">	function calculatePair(twoNumbers){</td></tr><tr class="hit"><td class="line">54</td><td class="hits">3</td><td class="source">		var result = &quot;&quot;;</td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">56</td><td class="hits">3</td><td class="source">		var number1Struct = digitStructure[twoNumbers[0]];</td></tr><tr class="hit"><td class="line">57</td><td class="hits">3</td><td class="source">		var number2Struct = digitStructure[twoNumbers[1]];</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source">		//Take every second bit and add to the result</td></tr><tr class="hit"><td class="line">60</td><td class="hits">3</td><td class="source">		for(var i=0;i&lt;5;i++){</td></tr><tr class="hit"><td class="line">61</td><td class="hits">15</td><td class="source">			result += (number1Struct[i]==&quot;1&quot;) ? &quot;111&quot; : &quot;1&quot;;</td></tr><tr class="hit"><td class="line">62</td><td class="hits">15</td><td class="source">			result += (number2Struct[i]==&quot;1&quot;) ? &quot;000&quot; : &quot;0&quot;;</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source">		}</td></tr><tr class="hit"><td class="line">64</td><td class="hits">3</td><td class="source">		return result;</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">67</td><td class="hits">6</td><td class="source">	function valid(number){</td></tr><tr class="hit"><td class="line">68</td><td class="hits">4</td><td class="source">		return number.search(regexp)!==-1;</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">73</td><td class="hits">1</td><td class="source">var register = function(core){</td></tr><tr class="hit"><td class="line">74</td><td class="hits">1</td><td class="source">	core.register(ITF, /^ITF$/i, 4);</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source">};</td></tr><tr class="hit"><td class="line">76</td><td class="hits">2</td><td class="source">try{register(JsBarcode)} catch(e){}</td></tr><tr class="hit"><td class="line">77</td><td class="hits">2</td><td class="source">try{module.exports.register = register} catch(e){}</td></tr><tr><td class="line">78</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/ITF14.js">/home/johan/DevZone/JsBarcode/barcodes/ITF14.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">41</div><div class="hits">41</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">function ITF14(string){</td></tr><tr class="hit"><td class="line">2</td><td class="hits">9</td><td class="source">	this.string = string+&quot;&quot;;</td></tr><tr><td class="line">3</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">5</td><td class="hits">1</td><td class="source">ITF14.prototype.getText = function(){</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">	return this.string;</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">9</td><td class="hits">1</td><td class="source">ITF14.prototype.valid = function(){</td></tr><tr class="hit"><td class="line">10</td><td class="hits">6</td><td class="source">	return valid(this.string);</td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">13</td><td class="hits">1</td><td class="source">ITF14.prototype.encoded = function(){</td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source">	//Create the variable that should be returned at the end of the function</td></tr><tr class="hit"><td class="line">15</td><td class="hits">2</td><td class="source">	var result = &quot;&quot;;</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source">	//If checksum is not already calculated, do it</td></tr><tr class="hit"><td class="line">18</td><td class="hits">2</td><td class="source">	if(this.string.length == 13){</td></tr><tr class="hit"><td class="line">19</td><td class="hits">1</td><td class="source">		this.string += checksum(this.string);</td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">21</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source">	//Always add the same start bits</td></tr><tr class="hit"><td class="line">23</td><td class="hits">2</td><td class="source">	result += startBin;</td></tr><tr><td class="line">24</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">	//Calculate all the digit pairs</td></tr><tr class="hit"><td class="line">26</td><td class="hits">2</td><td class="source">	for(var i=0;i&lt;14;i+=2){</td></tr><tr class="hit"><td class="line">27</td><td class="hits">14</td><td class="source">		result += calculatePair(this.string.substr(i,2));</td></tr><tr><td class="line">28</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source">	//Always add the same end bits</td></tr><tr class="hit"><td class="line">31</td><td class="hits">2</td><td class="source">	result += endBin;</td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">33</td><td class="hits">2</td><td class="source">	return result;</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">//The structure for the all digits, 1 is wide and 0 is narrow</td></tr><tr class="hit"><td class="line">37</td><td class="hits">1</td><td class="source">var digitStructure = {</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source"> &quot;0&quot;:&quot;00110&quot;</td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source">,&quot;1&quot;:&quot;10001&quot;</td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source">,&quot;2&quot;:&quot;01001&quot;</td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source">,&quot;3&quot;:&quot;11000&quot;</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source">,&quot;4&quot;:&quot;00101&quot;</td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source">,&quot;5&quot;:&quot;10100&quot;</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">,&quot;6&quot;:&quot;01100&quot;</td></tr><tr><td class="line">45</td><td class="hits"></td><td class="source">,&quot;7&quot;:&quot;00011&quot;</td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">,&quot;8&quot;:&quot;10010&quot;</td></tr><tr><td class="line">47</td><td class="hits"></td><td class="source">,&quot;9&quot;:&quot;01010&quot;}</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">//The start bits</td></tr><tr class="hit"><td class="line">50</td><td class="hits">1</td><td class="source">var startBin = &quot;1010&quot;;</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">//The end bits</td></tr><tr class="hit"><td class="line">52</td><td class="hits">1</td><td class="source">var endBin = &quot;11101&quot;;</td></tr><tr><td class="line">53</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">54</td><td class="hits"></td><td class="source">//Regexp for a valid ITF14 code</td></tr><tr class="hit"><td class="line">55</td><td class="hits">1</td><td class="source">var regexp = /^[0-9]{13,14}$/;</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">57</td><td class="hits"></td><td class="source">//Calculate the data of a number pair</td></tr><tr class="hit"><td class="line">58</td><td class="hits">1</td><td class="source">function calculatePair(twoNumbers){</td></tr><tr class="hit"><td class="line">59</td><td class="hits">14</td><td class="source">	var result = &quot;&quot;;</td></tr><tr><td class="line">60</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">61</td><td class="hits">14</td><td class="source">	var number1Struct = digitStructure[twoNumbers[0]];</td></tr><tr class="hit"><td class="line">62</td><td class="hits">14</td><td class="source">	var number2Struct = digitStructure[twoNumbers[1]];</td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source">	//Take every second bit and add to the result</td></tr><tr class="hit"><td class="line">65</td><td class="hits">14</td><td class="source">	for(var i=0;i&lt;5;i++){</td></tr><tr class="hit"><td class="line">66</td><td class="hits">70</td><td class="source">		result += (number1Struct[i]==&quot;1&quot;) ? &quot;111&quot; : &quot;1&quot;;</td></tr><tr class="hit"><td class="line">67</td><td class="hits">70</td><td class="source">		result += (number2Struct[i]==&quot;1&quot;) ? &quot;000&quot; : &quot;0&quot;;</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">69</td><td class="hits">14</td><td class="source">	return result;</td></tr><tr><td class="line">70</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source">//Calulate the checksum digit</td></tr><tr class="hit"><td class="line">73</td><td class="hits">1</td><td class="source">function checksum(numberString){</td></tr><tr class="hit"><td class="line">74</td><td class="hits">3</td><td class="source">	var result = 0;</td></tr><tr><td class="line">75</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">76</td><td class="hits">42</td><td class="source">	for(var i=0;i&lt;13;i++){result+=parseInt(numberString[i])*(3-(i%2)*2)}</td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">78</td><td class="hits">3</td><td class="source">	return 10 - (result % 10);</td></tr><tr><td class="line">79</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">80</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">81</td><td class="hits">1</td><td class="source">function valid(number){</td></tr><tr class="hit"><td class="line">82</td><td class="hits">6</td><td class="source">	if(number.search(regexp)==-1){</td></tr><tr class="hit"><td class="line">83</td><td class="hits">3</td><td class="source">		return false;</td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">85</td><td class="hits"></td><td class="source">	//Check checksum if it is already calculated</td></tr><tr class="hit"><td class="line">86</td><td class="hits">3</td><td class="source">	else if(number.length==14){</td></tr><tr class="hit"><td class="line">87</td><td class="hits">2</td><td class="source">		return number[13] == checksum(number);</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">89</td><td class="hits">1</td><td class="source">	return true;</td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">92</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">93</td><td class="hits">1</td><td class="source">var register = function(core){</td></tr><tr class="hit"><td class="line">94</td><td class="hits">1</td><td class="source">	core.register(ITF14, /^ITF.?14$/i, 5);</td></tr><tr><td class="line">95</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">96</td><td class="hits">2</td><td class="source">try{register(JsBarcode)} catch(e){}</td></tr><tr class="hit"><td class="line">97</td><td class="hits">2</td><td class="source">try{module.exports.register = register} catch(e){}</td></tr><tr><td class="line">98</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/MSI.js">/home/johan/DevZone/JsBarcode/barcodes/MSI.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">63</div><div class="hits">63</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">var prototype = {};</td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">3</td><td class="hits">1</td><td class="source">prototype.getText = function(){</td></tr><tr class="hit"><td class="line">4</td><td class="hits">11</td><td class="source">	return this.string;</td></tr><tr><td class="line">5</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">7</td><td class="hits">1</td><td class="source">prototype.encoded = function(){</td></tr><tr class="hit"><td class="line">8</td><td class="hits">2</td><td class="source">	var ret = &quot;110&quot;;</td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">10</td><td class="hits">2</td><td class="source">	for(var i=0;i&lt;this.string.length;i++){</td></tr><tr class="hit"><td class="line">11</td><td class="hits">16</td><td class="source">		var digit = parseInt(this.string[i]);</td></tr><tr class="hit"><td class="line">12</td><td class="hits">16</td><td class="source">		var bin = digit.toString(2);</td></tr><tr class="hit"><td class="line">13</td><td class="hits">16</td><td class="source">		bin = addZeroes(bin, 4-bin.length);</td></tr><tr class="hit"><td class="line">14</td><td class="hits">16</td><td class="source">		for(var b=0;b&lt;bin.length;b++){</td></tr><tr class="hit"><td class="line">15</td><td class="hits">64</td><td class="source">			ret += bin[b]==0 ? &quot;100&quot; : &quot;110&quot;;</td></tr><tr><td class="line">16</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">17</td><td class="hits"></td><td class="source">	}</td></tr><tr><td class="line">18</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">19</td><td class="hits">2</td><td class="source">	ret += &quot;1001&quot;;</td></tr><tr class="hit"><td class="line">20</td><td class="hits">2</td><td class="source">	return ret;</td></tr><tr><td class="line">21</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">22</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">23</td><td class="hits">1</td><td class="source">prototype.valid = function(){</td></tr><tr class="hit"><td class="line">24</td><td class="hits">7</td><td class="source">	return this.string.search(/^[0-9]+$/) != -1;</td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">27</td><td class="hits">1</td><td class="source">function MSI(string){</td></tr><tr class="hit"><td class="line">28</td><td class="hits">5</td><td class="source">	this.string = &quot;&quot;+string;</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">31</td><td class="hits">1</td><td class="source">MSI.prototype = Object.create(prototype);</td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">33</td><td class="hits">1</td><td class="source">function MSI10(string){</td></tr><tr class="hit"><td class="line">34</td><td class="hits">3</td><td class="source">	this.string = &quot;&quot;+string;</td></tr><tr class="hit"><td class="line">35</td><td class="hits">3</td><td class="source">	this.string += mod10(this.string);</td></tr><tr><td class="line">36</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">37</td><td class="hits">1</td><td class="source">MSI10.prototype = Object.create(prototype);</td></tr><tr><td class="line">38</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">39</td><td class="hits">1</td><td class="source">function MSI11(string){</td></tr><tr class="hit"><td class="line">40</td><td class="hits">4</td><td class="source">	this.string = &quot;&quot; + string;</td></tr><tr class="hit"><td class="line">41</td><td class="hits">4</td><td class="source">	this.string += mod11(this.string);</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">43</td><td class="hits">1</td><td class="source">MSI11.prototype = Object.create(prototype);</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">45</td><td class="hits">1</td><td class="source">function MSI1010(string){</td></tr><tr class="hit"><td class="line">46</td><td class="hits">2</td><td class="source">	this.string = &quot;&quot; + string;</td></tr><tr class="hit"><td class="line">47</td><td class="hits">2</td><td class="source">	this.string += mod10(this.string);</td></tr><tr class="hit"><td class="line">48</td><td class="hits">2</td><td class="source">	this.string += mod10(this.string);</td></tr><tr><td class="line">49</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">50</td><td class="hits">1</td><td class="source">MSI1010.prototype = Object.create(prototype);</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">52</td><td class="hits">1</td><td class="source">function MSI1110(string){</td></tr><tr class="hit"><td class="line">53</td><td class="hits">2</td><td class="source">	this.string = &quot;&quot; + string;</td></tr><tr class="hit"><td class="line">54</td><td class="hits">2</td><td class="source">	this.string += mod11(this.string);</td></tr><tr class="hit"><td class="line">55</td><td class="hits">2</td><td class="source">	this.string += mod10(this.string);</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">57</td><td class="hits">1</td><td class="source">MSI1110.prototype = Object.create(prototype);</td></tr><tr><td class="line">58</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">59</td><td class="hits">1</td><td class="source">function mod10(number){</td></tr><tr class="hit"><td class="line">60</td><td class="hits">9</td><td class="source">	var sum = 0;</td></tr><tr class="hit"><td class="line">61</td><td class="hits">9</td><td class="source">	for(var i=0;i&lt;number.length;i++){</td></tr><tr class="hit"><td class="line">62</td><td class="hits">54</td><td class="source">		var n = parseInt(number[i]);</td></tr><tr class="hit"><td class="line">63</td><td class="hits">54</td><td class="source">		if((i + number.length) % 2 == 0){</td></tr><tr class="hit"><td class="line">64</td><td class="hits">24</td><td class="source">			sum += n;</td></tr><tr><td class="line">65</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source">		else{</td></tr><tr class="hit"><td class="line">67</td><td class="hits">30</td><td class="source">			sum += (n*2)%10 + Math.floor((n*2)/10)</td></tr><tr><td class="line">68</td><td class="hits"></td><td class="source">		}</td></tr><tr><td class="line">69</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">70</td><td class="hits">9</td><td class="source">	return (10-(sum%10))%10;</td></tr><tr><td class="line">71</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">73</td><td class="hits">1</td><td class="source">function mod11(number){</td></tr><tr class="hit"><td class="line">74</td><td class="hits">6</td><td class="source">	var sum = 0;</td></tr><tr class="hit"><td class="line">75</td><td class="hits">6</td><td class="source">	var weights = [2,3,4,5,6,7];</td></tr><tr class="hit"><td class="line">76</td><td class="hits">6</td><td class="source">	for(var i=0;i&lt;number.length;i++){</td></tr><tr class="hit"><td class="line">77</td><td class="hits">46</td><td class="source">		var n = parseInt(number[number.length-1-i]);</td></tr><tr class="hit"><td class="line">78</td><td class="hits">46</td><td class="source">		sum += weights[i % weights.length] * n;</td></tr><tr><td class="line">79</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">80</td><td class="hits">6</td><td class="source">	return (11-(sum%11))%11;</td></tr><tr><td class="line">81</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">83</td><td class="hits">1</td><td class="source">function addZeroes(number, n){</td></tr><tr class="hit"><td class="line">84</td><td class="hits">16</td><td class="source">	for(var i=0;i&lt;n;i++){</td></tr><tr class="hit"><td class="line">85</td><td class="hits">24</td><td class="source">		number = &quot;0&quot;+number;</td></tr><tr><td class="line">86</td><td class="hits"></td><td class="source">	}</td></tr><tr class="hit"><td class="line">87</td><td class="hits">16</td><td class="source">	return number;</td></tr><tr><td class="line">88</td><td class="hits"></td><td class="source">}</td></tr><tr><td class="line">89</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">90</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">91</td><td class="hits">1</td><td class="source">var register = function(core){</td></tr><tr class="hit"><td class="line">92</td><td class="hits">1</td><td class="source">	core.register(MSI, /^MSI$/i, 4);</td></tr><tr class="hit"><td class="line">93</td><td class="hits">1</td><td class="source">	core.register(MSI10, /^MSI.?10$/i);</td></tr><tr class="hit"><td class="line">94</td><td class="hits">1</td><td class="source">	core.register(MSI11, /^MSI.?11$/i);</td></tr><tr class="hit"><td class="line">95</td><td class="hits">1</td><td class="source">	core.register(MSI1010, /^MSI.?1010$/i);</td></tr><tr class="hit"><td class="line">96</td><td class="hits">1</td><td class="source">	core.register(MSI1110, /^MSI.?1110$/i);</td></tr><tr><td class="line">97</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">98</td><td class="hits">2</td><td class="source">try{register(JsBarcode)} catch(e){}</td></tr><tr class="hit"><td class="line">99</td><td class="hits">2</td><td class="source">try{module.exports.register = register} catch(e){}</td></tr><tr><td class="line">100</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div><div class="file"><h2 id="/home/johan/DevZone/JsBarcode/barcodes/pharmacode.js">/home/johan/DevZone/JsBarcode/barcodes/pharmacode.js</h2><div id="stats" class="high"><div class="percentage">100%</div><div class="sloc">32</div><div class="hits">32</div><div class="misses">0</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr class="hit"><td class="line">1</td><td class="hits">1</td><td class="source">function pharmacode(number){</td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source">    //Ensure that the input is inturpreted as a number</td></tr><tr class="hit"><td class="line">3</td><td class="hits">6</td><td class="source">    this.number = parseInt(number);</td></tr><tr><td class="line">4</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">5</td><td class="hits">6</td><td class="source">    this.getText = function(){</td></tr><tr class="hit"><td class="line">6</td><td class="hits">1</td><td class="source">      return this.number + &quot;&quot;;</td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source">    };</td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">9</td><td class="hits">6</td><td class="source">    function recursiveEncoding(code,state){</td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source">        //End condition</td></tr><tr class="hit"><td class="line">11</td><td class="hits">21</td><td class="source">        if(code.length == 0) return &quot;&quot;;</td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">13</td><td class="hits">15</td><td class="source">        var generated;</td></tr><tr class="hit"><td class="line">14</td><td class="hits">15</td><td class="source">        var nextState = false;</td></tr><tr class="hit"><td class="line">15</td><td class="hits">15</td><td class="source">        var nZeros = zeros(code);</td></tr><tr class="hit"><td class="line">16</td><td class="hits">15</td><td class="source">        if(nZeros == 0){</td></tr><tr class="hit"><td class="line">17</td><td class="hits">7</td><td class="source">            generated = state ? &quot;001&quot; : &quot;00111&quot;;</td></tr><tr class="hit"><td class="line">18</td><td class="hits">7</td><td class="source">            nextState = state;</td></tr><tr><td class="line">19</td><td class="hits"></td><td class="source">        }</td></tr><tr><td class="line">20</td><td class="hits"></td><td class="source">        else{</td></tr><tr class="hit"><td class="line">21</td><td class="hits">8</td><td class="source">            generated = &quot;001&quot;.repeat(nZeros - (state ? 1 : 0));</td></tr><tr class="hit"><td class="line">22</td><td class="hits">8</td><td class="source">            generated += &quot;00111&quot;;</td></tr><tr><td class="line">23</td><td class="hits"></td><td class="source">        }</td></tr><tr class="hit"><td class="line">24</td><td class="hits">15</td><td class="source">        return recursiveEncoding(code.substr(0,code.length - nZeros - 1),nextState) + generated;</td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source">    };</td></tr><tr><td class="line">26</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">27</td><td class="hits">6</td><td class="source">    this.encoded = function(){</td></tr><tr class="hit"><td class="line">28</td><td class="hits">3</td><td class="source">      return recursiveEncoding(this.number.toString(2),true).substr(2);</td></tr><tr><td class="line">29</td><td class="hits"></td><td class="source">    };</td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"><td class="line">31</td><td class="hits">6</td><td class="source">    this.valid = function(){</td></tr><tr class="hit"><td class="line">32</td><td class="hits">2</td><td class="source">        return this.number &gt;= 3 &amp;&amp; this.number &lt;= 131070;</td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source">    };</td></tr><tr><td class="line">34</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">35</td><td class="hits"></td><td class="source">    //A help function to calculate the zeros at the end of a string (the code)</td></tr><tr class="hit"><td class="line">36</td><td class="hits">6</td><td class="source">    var zeros = function(code){</td></tr><tr class="hit"><td class="line">37</td><td class="hits">15</td><td class="source">        var i = code.length - 1;</td></tr><tr class="hit"><td class="line">38</td><td class="hits">15</td><td class="source">        var zeros = 0;</td></tr><tr class="hit"><td class="line">39</td><td class="hits">15</td><td class="source">        while(code[i]==&quot;0&quot; || i&lt;0){</td></tr><tr class="hit"><td class="line">40</td><td class="hits">13</td><td class="source">            zeros++;</td></tr><tr class="hit"><td class="line">41</td><td class="hits">13</td><td class="source">            i--;</td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source">        }</td></tr><tr class="hit"><td class="line">43</td><td class="hits">15</td><td class="source">        return zeros;</td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source">    };</td></tr><tr><td class="line">45</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">46</td><td class="hits"></td><td class="source">    //http://stackoverflow.com/a/202627</td></tr><tr class="hit"><td class="line">47</td><td class="hits">6</td><td class="source">    String.prototype.repeat = function( num )</td></tr><tr><td class="line">48</td><td class="hits"></td><td class="source">    {</td></tr><tr class="hit"><td class="line">49</td><td class="hits">8</td><td class="source">        return new Array( num + 1 ).join( this );</td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source">    }</td></tr><tr><td class="line">51</td><td class="hits"></td><td class="source">};</td></tr><tr><td class="line">52</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">53</td><td class="hits"></td><td class="source">//Required to register for both browser and nodejs</td></tr><tr class="hit"><td class="line">54</td><td class="hits">1</td><td class="source">var register = function(core){</td></tr><tr class="hit"><td class="line">55</td><td class="hits">1</td><td class="source">  core.register(pharmacode, /^pharmacode$/i, 2);</td></tr><tr><td class="line">56</td><td class="hits"></td><td class="source">}</td></tr><tr class="hit"><td class="line">57</td><td class="hits">2</td><td class="source">try{register(JsBarcode)} catch(e){}</td></tr><tr class="hit"><td class="line">58</td><td class="hits">2</td><td class="source">try{module.exports.register = register} catch(e){}</td></tr><tr><td class="line">59</td><td class="hits"></td><td class="source"> </td></tr></tbody></table></div></div></div></body></html>